Package weka.classifiers.functions
Class LibLINEAR
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.functions.LibLINEAR
- All Implemented Interfaces:
Serializable
,Cloneable
,CapabilitiesHandler
,OptionHandler
,RevisionHandler
,TechnicalInformationHandler
A wrapper class for the liblinear tools (the liblinear classes, typically the jar file, need to be in the classpath to use this classifier).
Rong-En Fan, Kai-Wei Chang, Cho-Jui Hsieh, Xiang-Rui Wang, Chih-Jen Lin (2008). LIBLINEAR - A Library for Large Linear Classification. URL http://www.csie.ntu.edu.tw/~cjlin/liblinear/. BibTeX:
Rong-En Fan, Kai-Wei Chang, Cho-Jui Hsieh, Xiang-Rui Wang, Chih-Jen Lin (2008). LIBLINEAR - A Library for Large Linear Classification. URL http://www.csie.ntu.edu.tw/~cjlin/liblinear/. BibTeX:
@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) 0 = L2-regularized logistic regression 1 = L2-loss support vector machines (dual) 2 = L2-loss support vector machines (primal) 3 = L1-loss support vector machines (dual) 4 = multi-class support vector machines by Crammer and Singer
-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
- Version:
- $Revision: 5917 $
- Author:
- Benedikt Waldvogel (mail at bwaldvogel.de)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
SVM solver type L1-loss support vector machines (dual)static final int
SVM solver type L2-regularized logistic regressionstatic final int
SVM solver type L2-loss support vector machines (primal)static final int
SVM solver type L2-loss support vector machines (dual)static final int
SVM solver type multi-class support vector machines by Crammer and Singerstatic final Tag[]
SVM solver types -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the tip text for this propertyvoid
buildClassifier
(Instances insts) builds the classifierReturns the tip text for this propertyReturns the tip text for this propertydouble[]
distributionForInstance
(Instance instance) Computes the distribution for a given instance.Returns the tip text for this propertyReturns the tip text for this propertydouble
getBias()
Returns bias term value (default 1) No bias term is added if value < 0Returns default capabilities of the classifier.boolean
Gets whether conversion of nominal to binary is turned on.double
getCost()
Returns the cost parameter Cboolean
Gets whether automatic replacement of missing values is disabled.double
getEps()
Gets tolerance of termination criteriongetModel()
boolean
whether to normalize input dataString[]
Returns the current optionsboolean
Sets whether to generate probability estimates instead of -1/+1 for classification problems.Returns the revision string.Gets type of SVMReturns 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.Gets the parameters C of class i to weight[i]*C (default 1).Returns a string describing classifierstatic boolean
returns whether the liblinear classes are present or not, i.e.Returns an enumeration describing the available options.static void
Main method for testing this class.Returns the tip text for this propertyReturns the tip text for this propertyvoid
setBias
(double value) Sets bias term value (default 1) No bias term is added if value < 0void
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 datavoid
setOptions
(String[] options) Sets the classifier optionsvoid
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
(String weightsStr) Sets the parameters C of class i to weight[i]*C (default 1).Returns the tip text for this propertytoString()
returns a string representationReturns the tip text for this propertyMethods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
-
Field Details
-
SVMTYPE_L2_LR
public static final int SVMTYPE_L2_LRSVM solver type L2-regularized logistic regression- See Also:
-
SVMTYPE_L2LOSS_SVM_DUAL
public static final int SVMTYPE_L2LOSS_SVM_DUALSVM solver type L2-loss support vector machines (dual)- See Also:
-
SVMTYPE_L2LOSS_SVM
public static final int SVMTYPE_L2LOSS_SVMSVM solver type L2-loss support vector machines (primal)- See Also:
-
SVMTYPE_L1LOSS_SVM_DUAL
public static final int SVMTYPE_L1LOSS_SVM_DUALSVM solver type L1-loss support vector machines (dual)- See Also:
-
SVMTYPE_MCSVM_CS
public static final int SVMTYPE_MCSVM_CSSVM solver type multi-class support vector machines by Crammer and Singer- See Also:
-
TAGS_SVMTYPE
SVM solver types
-
-
Constructor Details
-
LibLINEAR
public LibLINEAR()
-
-
Method Details
-
getModel
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
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.- Specified by:
getTechnicalInformation
in interfaceTechnicalInformationHandler
- Returns:
- the technical information about this class
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classClassifier
- Returns:
- an enumeration of all the available options.
-
setOptions
Sets the classifier options Valid options are:-S <int> Set type of solver (default: 1) 0 = L2-regularized logistic regression 1 = L2-loss support vector machines (dual) 2 = L2-loss support vector machines (primal) 3 = L1-loss support vector machines (dual) 4 = multi-class support vector machines by Crammer and Singer
-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
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classClassifier
- Parameters:
options
- the options to parse- Throws:
Exception
- if parsing fails
-
getOptions
Returns the current options- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classClassifier
- Returns:
- the current setup
-
isPresent
public static boolean isPresent()returns whether the liblinear classes are present or not, i.e. whether the classes are in the classpath or not- Returns:
- whether the liblinear classes are available
-
setSVMType
Sets type of SVM (default SVMTYPE_L2)- Parameters:
value
- the type of the SVM
-
getSVMType
Gets type of SVM- Returns:
- the type of the SVM
-
SVMTypeTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCost
public void setCost(double value) Sets the cost parameter C (default 1)- Parameters:
value
- the cost value
-
getCost
public double getCost()Returns the cost parameter C- Returns:
- the cost value
-
costTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setEps
public void setEps(double value) Sets tolerance of termination criterion (default 0.001)- Parameters:
value
- the tolerance
-
getEps
public double getEps()Gets tolerance of termination criterion- Returns:
- the current tolerance
-
epsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setBias
public void setBias(double value) Sets bias term value (default 1) No bias term is added if value < 0- Parameters:
value
- the bias term value
-
getBias
public double getBias()Returns bias term value (default 1) No bias term is added if value < 0- Returns:
- the bias term value
-
biasTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
normalizeTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNormalize
public void setNormalize(boolean value) whether to normalize input data- Parameters:
value
- whether to normalize the data
-
getNormalize
public boolean getNormalize()whether to normalize input data- Returns:
- true, if the data is normalized
-
convertNominalToBinaryTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setConvertNominalToBinary
public void setConvertNominalToBinary(boolean b) Whether to turn on conversion of nominal attributes to binary.- Parameters:
b
- true if nominal to binary conversion is to be turned on
-
getConvertNominalToBinary
public boolean getConvertNominalToBinary()Gets whether conversion of nominal to binary is turned on.- Returns:
- true if nominal to binary conversion is turned on.
-
doNotReplaceMissingValuesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setDoNotReplaceMissingValues
public void setDoNotReplaceMissingValues(boolean b) Whether to turn off automatic replacement of missing values. Set to true only if the data does not contain missing values.- Parameters:
b
- true if automatic missing values replacement is to be disabled.
-
getDoNotReplaceMissingValues
public boolean getDoNotReplaceMissingValues()Gets whether automatic replacement of missing values is disabled.- Returns:
- true if automatic replacement of missing values is disabled.
-
setWeights
Sets the parameters C of class i to weight[i]*C (default 1). Blank separated list of doubles.- Parameters:
weightsStr
- the weights (doubles, separated by blanks)
-
getWeights
Gets the parameters C of class i to weight[i]*C (default 1). Blank separated doubles.- Returns:
- the weights (doubles separated by blanks)
-
weightsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setProbabilityEstimates
public void setProbabilityEstimates(boolean value) Returns whether probability estimates are generated instead of -1/+1 for classification problems.- Parameters:
value
- whether to predict probabilities
-
getProbabilityEstimates
public boolean getProbabilityEstimates()Sets whether to generate probability estimates instead of -1/+1 for classification problems.- Returns:
- true, if probability estimates should be returned
-
probabilityEstimatesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
distributionForInstance
Computes the distribution for a given instance.- Overrides:
distributionForInstance
in classClassifier
- Parameters:
instance
- the instance for which distribution is computed- Returns:
- the distribution
- Throws:
Exception
- if the distribution can't be computed successfully
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classClassifier
- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
builds the classifier- Specified by:
buildClassifier
in classClassifier
- Parameters:
insts
- the training instances- Throws:
Exception
- if liblinear classes not in classpath or liblinear encountered a problem
-
toString
returns a string representation -
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classClassifier
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
args
- the options
-