|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.DistributionClassifier
weka.classifiers.sparse.SVMlight
A wrapper for SVMlight package by Thorsten Joachims For more information, see
http://www.cs.cornell.edu/People/tj/svm_light Valid options are:
Field Summary | |
static int |
KERNEL_LINEAR
Kernel type |
static int |
KERNEL_POLYNOMIAL
|
static int |
KERNEL_RBF
|
static int |
KERNEL_SIGMOID_TANH
|
protected boolean |
m_autoBounds
|
protected boolean |
m_biased
Use biased hyperplane (i.e. |
protected java.lang.String |
m_binPath
Path to the directory where SVM-light executables are located |
protected boolean |
m_bufferedMode
Is classification done via temporary files or via a buffer? |
protected double |
m_C
trade-off between training error and margin (default 0 corresponds to [avg. |
protected double |
m_c1
parameter c in sigmoid/poly kernel |
protected double |
m_costFactor
Cost: cost-factor, by which training errors on positive examples outweight errors on negative examples |
protected int |
m_d
Parameter d in polynomial kernel |
protected boolean |
m_debug
Output debugging information |
protected double |
m_gamma
Parameter gamma in rbf kernel |
protected int |
m_kernelType
|
protected double |
m_maxMargin
SVM-light predictions are positive or negative margins; to convert to a distribution we need min/max margin values... |
protected double |
m_minMargin
|
protected int |
m_mode
|
protected java.lang.String |
m_modelFilename
|
protected java.lang.String |
m_modelFilenameBase
Name of the file where a model will be temporarily created |
protected java.lang.String |
m_predictionFilename
|
protected java.lang.String |
m_predictionFilenameBase
Name of the file where predictions will be temporarily stored unless buffered IO is used |
protected java.io.BufferedReader |
m_procReader
|
protected java.io.BufferedWriter |
m_procWriter
|
protected boolean |
m_removeInconsistentExamples
remove inconsistent training examples and retrain |
protected double |
m_s
Parameter s in sigmoid/polynomial kernel |
protected boolean |
m_svmTrained
Has the SVM been trained |
protected java.io.File |
m_tempDirFile
|
protected java.lang.String |
m_tempDirPath
Path to the directory where temporary files will be stored |
protected java.lang.String |
m_testFilename
|
protected java.lang.String |
m_testFilenameBase
Name of the temporary file where a test instance is dumped if buffered IO is not used |
protected Instances |
m_train
The training instances used for classification. |
protected java.lang.String |
m_trainFilename
|
protected java.lang.String |
m_trainFilenameBase
Name of the temporary file where training data will be dumped temporarily |
protected int |
m_verbosityLevel
verbosity level |
protected double |
m_width
Epsilon width of tube for regression |
static int |
SVM_MODE_CLASSIFICATION
SVM-light can work in classification, regression and preference ranking modes |
static int |
SVM_MODE_PREFERENCE_RANKING
|
static int |
SVM_MODE_REGRESSION
|
static Tag[] |
TAGS_KERNEL_TYPE
|
static Tag[] |
TAGS_SVM_MODE
|
Constructor Summary | |
SVMlight()
A default constructor |
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
protected double |
classifySVMlight(Instance instance)
Launch an SVM-light process and classify a given instance |
protected void |
cleanupIO()
The buffered version of SVM-light needs to release some I/O resources before exiting |
static java.lang.String |
concatStringArray(java.lang.String[] strings)
A little helper to create a single String from an array of Strings |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
protected void |
dumpInstance(Instance instance,
java.io.File file)
Dump a single instance into a file in SVM-light format |
protected void |
dumpTrainingData(Instances instances)
Dump training instances into a file in SVM-light format |
protected void |
finalize()
Take care of closing the SVM-light process before the object is destroyed |
boolean |
getAutoBounds()
Get whether min/max margins are determined automatically |
boolean |
getBiased()
Get whether the hyperplane is biased (i.e. |
java.lang.String |
getBinPath()
Get the path for the binaries |
boolean |
getBufferedMode()
See whether SVM-light is operating via in/out bufffers or via temporary files |
double |
getC()
Get the trade-off between training error and margin (default 0 corresponds to [avg. |
double |
getC1()
Get parameter c in sigmoid/poly kernel |
double |
getCostFactor()
Get cost-factor, by which training errors on positive examples outweight errors on negative examples |
int |
getD()
Get parameter d in polynomial kernel |
boolean |
getDebug()
See whether debugging output is on/off |
double |
getGamma()
Get parameter gamma in rbf kernel |
SelectedTag |
getKernelType()
Get the SVM-light kernel type |
double |
getMaxMargin()
Get the maxMargin that an SVM can return |
double |
getMinMargin()
Get the minMargin that an SVM can return |
SelectedTag |
getMode()
return the SVM-light mode |
java.lang.String[] |
getOptions()
Gets the current settings |
boolean |
getRemoveInconsistentExamples()
Get whether the inconsistent examples are removed and retraining follows |
double |
getS()
Get parameter s in sigmoid/polynomial kernel |
java.lang.String |
getTempDirPath()
Get the path for the temporary files |
int |
getVerbosityLevel()
Get verbosity level, can be anything between 0 and 3 |
double |
getWidth()
Get the epsilon width of tube for regression |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
protected double |
readPrediction(java.io.File file)
Read the prediction of SVM-light |
void |
setAutoBounds(boolean autoBounds)
Set whether min/max margins are determined automatically |
void |
setBiased(boolean biased)
Set whether the hyperplane is biased (i.e. |
void |
setBinPath(java.lang.String binPath)
Set the path for the binary files |
protected void |
setBounds(Instances data)
Set the bounds using "extreme" training examples - TODO! |
void |
setBufferedMode(boolean bufferedMode)
Set SVM-light to operate via in/out bufffers or via temporary files |
void |
setC(double C)
Set the trade-off between training error and margin (default 0 corresponds to [avg. |
void |
setC1(double c1)
Set parameter c in sigmoid/poly kernel |
void |
setCostFactor(double costFactor)
Set cost-factor, by which training errors on positive examples outweight errors on negative examples |
void |
setD(int d)
Set parameter d in polynomial kernel |
void |
setDebug(boolean debug)
Turn debugging output on/off |
void |
setGamma(double gamma)
Set parameter gamma in rbf kernel |
void |
setKernelType(SelectedTag kernelType)
Set the kernel type for SVM-light |
void |
setMaxMargin(double maxMargin)
Set the maxMargin that an SVM can return |
void |
setMinMargin(double minMargin)
Set the minMargin that an SVM can return |
void |
setMode(SelectedTag mode)
Set the mode of the SVM |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setRemoveInconsistentExamples(boolean removeInconsistentExamples)
Set whether the inconsistent examples are removed and retraining follows |
void |
setS(double s)
Set parameter s in sigmoid/polynomial kernel |
void |
setTempDirPath(java.lang.String tempDirPath)
Set the path for the temporary files |
void |
setVerbosityLevel(int verbosity)
Set verbosity level, can be anything between 0 and 3 |
void |
setWidth(double width)
Set the epsilon width of tube for regression |
java.lang.String |
toString()
Returns a description of this classifier. |
boolean |
trained()
Check whether the SVM has been trained |
protected void |
trainSVMlight()
Launch an SVM-light process assuming that the training data has been dumped |
Methods inherited from class weka.classifiers.DistributionClassifier |
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance |
Methods inherited from class weka.classifiers.Classifier |
forName, makeCopies |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Instances m_train
protected boolean m_svmTrained
protected boolean m_debug
protected java.lang.String m_binPath
protected java.lang.String m_tempDirPath
protected java.io.File m_tempDirFile
protected java.lang.String m_trainFilenameBase
protected java.lang.String m_trainFilename
protected java.lang.String m_testFilenameBase
protected java.lang.String m_testFilename
protected java.lang.String m_modelFilenameBase
protected java.lang.String m_modelFilename
protected java.lang.String m_predictionFilenameBase
protected java.lang.String m_predictionFilename
protected double m_maxMargin
protected double m_minMargin
protected boolean m_autoBounds
protected boolean m_bufferedMode
protected java.io.BufferedReader m_procReader
protected java.io.BufferedWriter m_procWriter
protected int m_verbosityLevel
public static final int SVM_MODE_CLASSIFICATION
public static final int SVM_MODE_REGRESSION
public static final int SVM_MODE_PREFERENCE_RANKING
public static final Tag[] TAGS_SVM_MODE
protected int m_mode
protected double m_C
protected double m_width
protected double m_costFactor
protected boolean m_biased
protected boolean m_removeInconsistentExamples
public static final int KERNEL_LINEAR
public static final int KERNEL_POLYNOMIAL
public static final int KERNEL_RBF
public static final int KERNEL_SIGMOID_TANH
public static final Tag[] TAGS_KERNEL_TYPE
protected int m_kernelType
protected int m_d
protected double m_gamma
protected double m_s
protected double m_c1
Constructor Detail |
public SVMlight()
Method Detail |
protected void finalize()
protected void cleanupIO()
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been generated successfullyprotected void setBounds(Instances data)
protected void dumpTrainingData(Instances instances)
instances
- the training instancesprotected void dumpInstance(Instance instance, java.io.File file)
instance
- an instancefile
- the file where instance will be dumpedprotected void trainSVMlight()
protected double classifySVMlight(Instance instance)
instance
- an instance that must be classifiedprotected double readPrediction(java.io.File file)
file
- file where the prediction is storedpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class DistributionClassifier
instance
- the instance to be classified
java.lang.Exception
- if an error occurred during the predictionpublic boolean trained()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-D
output debugging information
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void setDebug(boolean debug)
debug
- if true, SVM-light output and other debugging info will be printedpublic boolean getDebug()
public void setBufferedMode(boolean bufferedMode)
bufferedMode
- if true, SVM-light classification is performed via stdin/stdoutpublic boolean getBufferedMode()
public void setVerbosityLevel(int verbosity)
verbosity
- Verbosity level for SVM-lightpublic int getVerbosityLevel()
public void setMode(SelectedTag mode)
mode
- one of classification, regression and preference rankingpublic SelectedTag getMode()
public void setWidth(double width)
public double getWidth()
public void setC(double C)
public double getC()
public void setCostFactor(double costFactor)
public double getCostFactor()
public void setBiased(boolean biased)
biased
- if true, the hyperplane will be biasedpublic boolean getBiased()
public void setRemoveInconsistentExamples(boolean removeInconsistentExamples)
removeInconsistentExamples
- public boolean getRemoveInconsistentExamples()
public void setKernelType(SelectedTag kernelType)
public SelectedTag getKernelType()
public void setD(int d)
public int getD()
public void setGamma(double gamma)
public double getGamma()
public void setS(double s)
public double getS()
public void setC1(double c1)
public double getC1()
public void setMaxMargin(double maxMargin)
public double getMaxMargin()
public void setMinMargin(double minMargin)
public double getMinMargin()
public void setAutoBounds(boolean autoBounds)
public boolean getAutoBounds()
public java.lang.String toString()
public void setTempDirPath(java.lang.String tempDirPath)
tempDirPath
- a full path to the temporary directorypublic java.lang.String getTempDirPath()
public void setBinPath(java.lang.String binPath)
public java.lang.String getBinPath()
public static java.lang.String concatStringArray(java.lang.String[] strings)
strings
- an array of stringspublic static void main(java.lang.String[] argv)
argv
- should contain command line options (see setOptions)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |