public class LibLINEAR extends Classifier 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) 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
Modifier and Type | Field and Description |
---|---|
protected static String |
CLASS_FEATURENODE
the svm_node classname
|
protected static String |
CLASS_LINEAR
the svm classname
|
protected static String |
CLASS_MODEL
the svm_model classname
|
protected static String |
CLASS_PARAMETER
the svm_parameter classname
|
protected static String |
CLASS_PROBLEM
the svm_problem classname
|
protected static String |
CLASS_SOLVERTYPE
the svm_parameter classname
|
protected double |
m_Bias
bias term value
|
protected double |
m_Cost
cost Parameter C
|
protected double |
m_eps
stopping criteria
|
protected Filter |
m_Filter
for normalizing the data
|
protected Object |
m_Model
LibLINEAR Model
|
protected NominalToBinary |
m_NominalToBinary
The filter used to make attributes numeric.
|
protected boolean |
m_Normalize
normalize input data
|
protected static boolean |
m_Present
whether the liblinear classes are in the Classpath
|
protected boolean |
m_ProbabilityEstimates
whether to generate probability estimates instead of +1/-1 in case of
classification problems
|
protected ReplaceMissingValues |
m_ReplaceMissingValues
The filter used to get rid of missing values.
|
protected int |
m_SVMType
the SVM solver type
|
protected double[] |
m_Weight |
protected int[] |
m_WeightLabel |
protected static long |
serialVersionUID
serial UID
|
static int |
SVMTYPE_L1LOSS_SVM_DUAL
SVM solver type L1-loss support vector machines (dual)
|
static int |
SVMTYPE_L2_LR
SVM solver type L2-regularized logistic regression
|
static int |
SVMTYPE_L2LOSS_SVM
SVM solver type L2-loss support vector machines (primal)
|
static int |
SVMTYPE_L2LOSS_SVM_DUAL
SVM solver type L2-loss support vector machines (dual)
|
static int |
SVMTYPE_MCSVM_CS
SVM solver type multi-class support vector machines by Crammer and Singer
|
static Tag[] |
TAGS_SVMTYPE
SVM solver types
|
m_Debug
Constructor and Description |
---|
LibLINEAR() |
Modifier and Type | Method and Description |
---|---|
String |
biasTipText()
Returns the tip text for this property
|
void |
buildClassifier(Instances insts)
builds the classifier
|
String |
convertNominalToBinaryTipText()
Returns the tip text for this property
|
String |
costTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Computes the distribution for a given instance.
|
String |
doNotReplaceMissingValuesTipText()
Returns the tip text for this property
|
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
|
protected Object |
getField(Object o,
String name)
returns the current value of the specified field
|
Object |
getModel() |
boolean |
getNormalize()
whether to normalize input data
|
String[] |
getOptions()
Returns the current options
|
protected Object |
getParameters()
transfers the local variables into a svm_parameter object
|
boolean |
getProbabilityEstimates()
Sets whether to generate probability estimates instead of -1/+1 for
classification problems.
|
protected Object |
getProblem(List<Object> vx,
List<Integer> vy,
int max_index)
returns the svm_problem
|
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.
|
String |
getWeights()
Gets the parameters C of class i to weight[i]*C (default 1).
|
String |
globalInfo()
Returns a string describing classifier
|
protected Object |
instanceToArray(Instance instance)
returns an instance into a sparse liblinear array
|
protected Object |
invokeMethod(Object o,
String name,
Class[] paramClasses,
Object[] paramValues)
executes the specified method and returns the result, if any
|
static boolean |
isPresent()
returns whether the liblinear classes are present or not, i.e.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] args)
Main method for testing this class.
|
protected void |
newArray(Object o,
String name,
Class type,
int length)
sets a new array for the field
|
protected void |
newArray(Object o,
String name,
Class type,
int[] dimensions)
sets a new array for the field
|
String |
normalizeTipText()
Returns the tip text for this property
|
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)
|
protected void |
setField(Object o,
String name,
int index,
Object value)
sets the specified field in an array
|
protected void |
setField(Object o,
String name,
Object value)
sets the specified field
|
void |
setNormalize(boolean value)
whether to normalize input data
|
void |
setOptions(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(String weightsStr)
Sets the parameters C of class i to weight[i]*C (default 1).
|
String |
SVMTypeTipText()
Returns the tip text for this property
|
String |
toString()
returns a string representation
|
String |
weightsTipText()
Returns the tip text for this property
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
protected static final String CLASS_LINEAR
protected static final String CLASS_MODEL
protected static final String CLASS_PROBLEM
protected static final String CLASS_PARAMETER
protected static final String CLASS_SOLVERTYPE
protected static final String CLASS_FEATURENODE
protected static final long serialVersionUID
protected Object m_Model
protected Filter m_Filter
protected boolean m_Normalize
public static final int SVMTYPE_L2_LR
public static final int SVMTYPE_L2LOSS_SVM_DUAL
public static final int SVMTYPE_L2LOSS_SVM
public static final int SVMTYPE_L1LOSS_SVM_DUAL
public static final int SVMTYPE_MCSVM_CS
public static final Tag[] TAGS_SVMTYPE
protected int m_SVMType
protected double m_eps
protected double m_Cost
protected double m_Bias
protected int[] m_WeightLabel
protected double[] m_Weight
protected boolean m_ProbabilityEstimates
protected ReplaceMissingValues m_ReplaceMissingValues
protected NominalToBinary m_NominalToBinary
protected static boolean m_Present
public Object getModel()
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public void setOptions(String[] options) throws Exception
-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
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the options to parseException
- if parsing failspublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public static boolean isPresent()
public void setSVMType(SelectedTag value)
value
- the type of the SVMpublic SelectedTag getSVMType()
public String SVMTypeTipText()
public void setCost(double value)
value
- the cost valuepublic double getCost()
public String costTipText()
public void setEps(double value)
value
- the tolerancepublic double getEps()
public String epsTipText()
public void setBias(double value)
value
- the bias term valuepublic double getBias()
public String biasTipText()
public String normalizeTipText()
public void setNormalize(boolean value)
value
- whether to normalize the datapublic boolean getNormalize()
public String convertNominalToBinaryTipText()
public void setConvertNominalToBinary(boolean b)
b
- true if nominal to binary conversion is to be
turned onpublic boolean getConvertNominalToBinary()
public String doNotReplaceMissingValuesTipText()
public void setDoNotReplaceMissingValues(boolean b)
b
- true if automatic missing values replacement is
to be disabled.public boolean getDoNotReplaceMissingValues()
public void setWeights(String weightsStr)
weightsStr
- the weights (doubles, separated by blanks)public String getWeights()
public String weightsTipText()
public void setProbabilityEstimates(boolean value)
value
- whether to predict probabilitiespublic boolean getProbabilityEstimates()
public String probabilityEstimatesTipText()
protected void setField(Object o, String name, Object value)
o
- the object to set the field forname
- the name of the fieldvalue
- the new value of the fieldprotected void setField(Object o, String name, int index, Object value)
o
- the object to set the field forname
- the name of the fieldindex
- the index in the arrayvalue
- the new value of the fieldprotected Object getField(Object o, String name)
o
- the object the field is member ofname
- the name of the fieldprotected void newArray(Object o, String name, Class type, int length)
o
- the object to set the array forname
- the name of the fieldtype
- the type of the arraylength
- the length of the one-dimensional arrayprotected void newArray(Object o, String name, Class type, int[] dimensions)
o
- the object to set the array forname
- the name of the fieldtype
- the type of the arraydimensions
- the dimensions of the arrayprotected Object invokeMethod(Object o, String name, Class[] paramClasses, Object[] paramValues)
o
- the object the method should be called fromname
- the name of the methodparamClasses
- the classes of the parametersparamValues
- the values of the parametersprotected Object getParameters()
protected Object getProblem(List<Object> vx, List<Integer> vy, int max_index)
vx
- the x valuesvy
- the y valuesmax_index
- protected Object instanceToArray(Instance instance) throws Exception
instance
- the instance to work onException
- if setup of array failspublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in class Classifier
instance
- the instance for which distribution is computedException
- if the distribution can't be computed successfullypublic Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Classifier
Capabilities
public void buildClassifier(Instances insts) throws Exception
buildClassifier
in class Classifier
insts
- the training instancesException
- if liblinear classes not in classpath or liblinear
encountered a problempublic String toString()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier
public static void main(String[] args)
args
- the optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.