public class LibLINEAR extends AbstractClassifier implements TechnicalInformationHandler
@misc{Fan2008, author = {Rong-En Fan and Kai-Wei Chang and Cho-Jui Hsieh and Xiang-Rui Wang and Chih-Jen Lin}, note = {The Weka classifier works with version 1.33 of LIBLINEAR}, title = {LIBLINEAR - A Library for Large Linear Classification}, year = {2008}, URL = {http://www.csie.ntu.edu.tw/\~cjlin/liblinear/} }Valid options are:
-S <int> Set type of solver (default: 1) for multi-class classification 0 -- L2-regularized logistic regression (primal) 1 -- L2-regularized L2-loss support vector classification (dual) 2 -- L2-regularized L2-loss support vector classification (primal) 3 -- L2-regularized L1-loss support vector classification (dual) 4 -- support vector classification by Crammer and Singer 5 -- L1-regularized L2-loss support vector classification 6 -- L1-regularized logistic regression 7 -- L2-regularized logistic regression (dual) for regression 11 -- L2-regularized L2-loss support vector regression (primal) 12 -- L2-regularized L2-loss support vector regression (dual) 13 -- L2-regularized L1-loss support vector regression (dual)
-C <double> Set the cost parameter C (default: 1)
-Z Turn on normalization of input data (default: off)
-N Turn on nominal to binary conversion.
-M Turn off missing value replacement. WARNING: use only if your data has no missing values.
-P Use probability estimation (default: off) currently for L2-regularized logistic regression only!
-E <double> Set tolerance of termination criterion (default: 0.01)
-W <double> Set the parameters C of class i to weight[i]*C (default: 1)
-B <double> Add Bias term with the given value if >= 0; if < 0, no bias term added (default: 1)
-D If set, classifier is run in debug mode and may output additional info to the console
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REVISION |
static Tag[] |
TAGS_SVMTYPE
SVM solver types
|
Constructor and Description |
---|
LibLINEAR() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
biasTipText()
Returns the tip text for this property
|
void |
buildClassifier(Instances insts)
builds the classifier
|
java.lang.String |
convertNominalToBinaryTipText()
Returns the tip text for this property
|
java.lang.String |
costTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Computes the distribution for a given instance.
|
java.lang.String |
doNotReplaceMissingValuesTipText()
Returns the tip text for this property
|
java.lang.String |
epsTipText()
Returns the tip text for this property
|
double |
getBias()
Returns bias term value (default 1)
No bias term is added if value < 0
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getConvertNominalToBinary()
Gets whether conversion of nominal to binary is
turned on.
|
double |
getCost()
Returns the cost parameter C
|
boolean |
getDoNotReplaceMissingValues()
Gets whether automatic replacement of missing values is
disabled.
|
double |
getEps()
Gets tolerance of termination criterion
|
de.bwaldvogel.liblinear.Model |
getModel() |
boolean |
getNormalize()
whether to normalize input data
|
java.lang.String[] |
getOptions()
Returns the current options
|
boolean |
getProbabilityEstimates()
Sets whether to generate probability estimates instead of -1/+1 for
classification problems.
|
java.lang.String |
getRevision()
Returns the revision string.
|
SelectedTag |
getSVMType()
Gets type of SVM
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
java.lang.String |
getWeights()
Gets the parameters C of class i to weight[i]*C (default 1).
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] args)
Main method for testing this class.
|
java.lang.String |
normalizeTipText()
Returns the tip text for this property
|
java.lang.String |
probabilityEstimatesTipText()
Returns the tip text for this property
|
void |
setBias(double value)
Sets bias term value (default 1)
No bias term is added if value < 0
|
void |
setConvertNominalToBinary(boolean b)
Whether to turn on conversion of nominal attributes
to binary.
|
void |
setCost(double value)
Sets the cost parameter C (default 1)
|
void |
setDoNotReplaceMissingValues(boolean b)
Whether to turn off automatic replacement of missing values.
|
void |
setEps(double value)
Sets tolerance of termination criterion (default 0.001)
|
void |
setNormalize(boolean value)
whether to normalize input data
|
void |
setOptions(java.lang.String[] options)
Sets the classifier options
Valid options are:
|
void |
setProbabilityEstimates(boolean value)
Returns whether probability estimates are generated instead of -1/+1 for
classification problems.
|
void |
setSVMType(SelectedTag value)
Sets type of SVM (default SVMTYPE_L2)
|
void |
setWeights(java.lang.String weightsStr)
Sets the parameters C of class i to weight[i]*C (default 1).
|
java.lang.String |
SVMTypeTipText()
Returns the tip text for this property
|
java.lang.String |
toString()
returns a string representation
|
java.lang.String |
weightsTipText()
Returns the tip text for this property
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
public static final java.lang.String REVISION
public static final Tag[] TAGS_SVMTYPE
public de.bwaldvogel.liblinear.Model getModel()
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class AbstractClassifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-S <int> Set type of solver (default: 1) for multi-class classification 0 -- L2-regularized logistic regression (primal) 1 -- L2-regularized L2-loss support vector classification (dual) 2 -- L2-regularized L2-loss support vector classification (primal) 3 -- L2-regularized L1-loss support vector classification (dual) 4 -- support vector classification by Crammer and Singer 5 -- L1-regularized L2-loss support vector classification 6 -- L1-regularized logistic regression 7 -- L2-regularized logistic regression (dual) for regression 11 -- L2-regularized L2-loss support vector regression (primal) 12 -- L2-regularized L2-loss support vector regression (dual) 13 -- L2-regularized L1-loss support vector regression (dual)
-C <double> Set the cost parameter C (default: 1)
-Z Turn on normalization of input data (default: off)
-N Turn on nominal to binary conversion.
-M Turn off missing value replacement. WARNING: use only if your data has no missing values.
-P Use probability estimation (default: off) currently for L2-regularized logistic regression only!
-E <double> Set tolerance of termination criterion (default: 0.01)
-W <double> Set the parameters C of class i to weight[i]*C (default: 1)
-B <double> Add Bias term with the given value if >= 0; if < 0, no bias term added (default: 1)
-D If set, classifier is run in debug mode and may output additional info to the console
setOptions
in interface OptionHandler
setOptions
in class AbstractClassifier
options
- the options to parsejava.lang.Exception
- if parsing failspublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public void setSVMType(SelectedTag value)
value
- the type of the SVMpublic SelectedTag getSVMType()
public java.lang.String SVMTypeTipText()
public void setCost(double value)
value
- the cost valuepublic double getCost()
public java.lang.String costTipText()
public void setEps(double value)
value
- the tolerancepublic double getEps()
public java.lang.String epsTipText()
public void setBias(double value)
value
- the bias term valuepublic double getBias()
public java.lang.String biasTipText()
public java.lang.String normalizeTipText()
public void setNormalize(boolean value)
value
- whether to normalize the datapublic boolean getNormalize()
public java.lang.String convertNominalToBinaryTipText()
public void setConvertNominalToBinary(boolean b)
b
- true if nominal to binary conversion is to be
turned onpublic boolean getConvertNominalToBinary()
public java.lang.String doNotReplaceMissingValuesTipText()
public void setDoNotReplaceMissingValues(boolean b)
b
- true if automatic missing values replacement is
to be disabled.public boolean getDoNotReplaceMissingValues()
public void setWeights(java.lang.String weightsStr)
weightsStr
- the weights (doubles, separated by blanks)public java.lang.String getWeights()
public java.lang.String weightsTipText()
public void setProbabilityEstimates(boolean value)
value
- whether to predict probabilitiespublic boolean getProbabilityEstimates()
public java.lang.String probabilityEstimatesTipText()
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance for which distribution is computedjava.lang.Exception
- if the distribution can't be computed successfullypublic Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class AbstractClassifier
public void buildClassifier(Instances insts) throws java.lang.Exception
buildClassifier
in interface Classifier
insts
- the training instancesjava.lang.Exception
- if liblinear classes not in classpath or liblinear
encountered a problempublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(java.lang.String[] args)
args
- the options