类 LibSVM
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.RandomizableClassifier
weka.classifiers.functions.LibSVM
- 所有已实现的接口:
Serializable
,Cloneable
,CapabilitiesHandler
,OptionHandler
,Randomizable
,RevisionHandler
,TechnicalInformationHandler
A wrapper class for the libsvm tools (the libsvm
classes, typically the jar file, need to be in the classpath to use this
classifier).
LibSVM runs faster than SMO since it uses LibSVM to build the SVM classifier.
LibSVM allows users to experiment with One-class SVM, Regressing SVM, and nu-SVM supported by LibSVM tool. LibSVM reports many useful statistics about LibSVM classifier (e.g., confusion matrix,precision, recall, ROC score, etc.).
Yasser EL-Manzalawy (2005). WLSVM. URL http://www.cs.iastate.edu/~yasser/wlsvm/.
Chih-Chung Chang, Chih-Jen Lin (2001). LIBSVM - A Library for Support Vector Machines. URL http://www.csie.ntu.edu.tw/~cjlin/libsvm/. BibTeX:
LibSVM runs faster than SMO since it uses LibSVM to build the SVM classifier.
LibSVM allows users to experiment with One-class SVM, Regressing SVM, and nu-SVM supported by LibSVM tool. LibSVM reports many useful statistics about LibSVM classifier (e.g., confusion matrix,precision, recall, ROC score, etc.).
Yasser EL-Manzalawy (2005). WLSVM. URL http://www.cs.iastate.edu/~yasser/wlsvm/.
Chih-Chung Chang, Chih-Jen Lin (2001). LIBSVM - A Library for Support Vector Machines. URL http://www.csie.ntu.edu.tw/~cjlin/libsvm/. BibTeX:
@misc{EL-Manzalawy2005, author = {Yasser EL-Manzalawy}, note = {You don't need to include the WLSVM package in the CLASSPATH}, title = {WLSVM}, year = {2005}, URL = {http://www.cs.iastate.edu/\~yasser/wlsvm/} } @misc{Chang2001, author = {Chih-Chung Chang and Chih-Jen Lin}, note = {The Weka classifier works with version 2.82 of LIBSVM}, title = {LIBSVM - A Library for Support Vector Machines}, year = {2001}, URL = {http://www.csie.ntu.edu.tw/\~cjlin/libsvm/} }Valid options are:
-S <int> Set type of SVM (default: 0) 0 = C-SVC 1 = nu-SVC 2 = one-class SVM 3 = epsilon-SVR 4 = nu-SVR
-K <int> Set type of kernel function (default: 2) 0 = linear: u'*v 1 = polynomial: (gamma*u'*v + coef0)^degree 2 = radial basis function: exp(-gamma*|u-v|^2) 3 = sigmoid: tanh(gamma*u'*v + coef0)
-D <int> Set degree in kernel function (default: 3)
-G <double> Set gamma in kernel function (default: 1/k)
-R <double> Set coef0 in kernel function (default: 0)
-C <double> Set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default: 1)
-N <double> Set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default: 0.5)
-Z Turns on normalization of input data (default: off)
-J Turn off nominal to binary conversion. WARNING: use only if your data is all numeric!
-V Turn off missing value replacement. WARNING: use only if your data has no missing values.
-P <double> Set the epsilon in loss function of epsilon-SVR (default: 0.1)
-M <double> Set cache memory size in MB (default: 40)
-E <double> Set tolerance of termination criterion (default: 0.001)
-H Turns the shrinking heuristics off (default: on)
-W <double> Set the parameters C of class i to weight[i]*C, for C-SVC E.g., for a 3-class problem, you could use "1 1 1" for equally weighted classes. (default: 1 for all classes)
-B Generate probability estimates for classification
-seed <num> Random seed (default = 1)
- 版本:
- $Revision: 10660 $
- 作者:
- Yasser EL-Manzalawy, FracPete (fracpete at waikato dot ac dot nz)
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final int
kernel type linear: u'*vstatic final int
kernel type polynomial: (gamma*u'*v + coef0)^degreestatic final int
kernel type radial basis function: exp(-gamma*|u-v|^2)static final int
kernel type sigmoid: tanh(gamma*u'*v + coef0)static final int
SVM type C-SVC (classification)static final int
SVM type epsilon-SVR (regression)static final int
SVM type nu-SVC (classification)static final int
SVM type nu-SVR (regression)static final int
SVM type one-class SVM (classification)static final Tag[]
the different kernel typesstatic final Tag[]
SVM types -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
buildClassifier
(Instances insts) builds the classifierReturns the tip text for this propertyReturns the tip text for this propertyReturns 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 propertyReturns the tip text for this propertydouble
Gets cache memory size in MBReturns default capabilities of the classifier.double
getCoef0()
Gets coefdouble
getCost()
Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVRint
Gets the degree of the kernelboolean
Gets whether automatic replacement of missing values is disabled.double
getEps()
Gets tolerance of termination criteriondouble
getGamma()
Gets gammaGets type of kernel functiondouble
getLoss()
Gets the epsilon in loss function of epsilon-SVRboolean
whether to normalize input datadouble
getNu()
Gets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)String[]
Returns the current optionsboolean
Sets whether to generate probability estimates instead of -1/+1 for classification problems.Returns the revision string.boolean
whether to use the shrinking heuristicsGets 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, for C-SVC (default 1).Returns a string describing classifierstatic boolean
returns whether the libsvm classes are present or not, i.e.Returns the tip text for this propertyReturns an enumeration describing the available options.Returns the tip text for this propertystatic void
Main method for testing this class.Returns the tip text for this propertyReturns the tip text for this propertyReturns the tip text for this propertyvoid
setCacheSize
(double value) Sets cache memory size in MB (default 40)void
setCoef0
(double value) Sets coef (default 0)void
setCost
(double value) Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)void
setDegree
(int value) Sets the degree of the kernelvoid
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
setGamma
(double value) Sets gamma (default = 1/no of attributes)void
setKernelType
(SelectedTag value) Sets type of kernel function (default KERNELTYPE_RBF)void
setLoss
(double value) Sets the epsilon in loss function of epsilon-SVR (default 0.1)void
setNormalize
(boolean value) whether to normalize input datavoid
setNu
(double value) Sets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)void
setOptions
(String[] options) Sets the classifier optionsvoid
setProbabilityEstimates
(boolean value) Returns whether probability estimates are generated instead of -1/+1 for classification problems.void
setShrinking
(boolean value) whether to use the shrinking heuristicsvoid
setSVMType
(SelectedTag value) Sets type of SVM (default SVMTYPE_C_SVC)void
setWeights
(String weightsStr) Sets the parameters C of class i to weight[i]*C, for C-SVC (default 1).Returns the tip text for this propertyReturns the tip text for this propertytoString()
returns a string representationReturns the tip text for this property从类继承的方法 weka.classifiers.RandomizableClassifier
getSeed, seedTipText, setSeed
从类继承的方法 weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
-
字段详细资料
-
SVMTYPE_C_SVC
public static final int SVMTYPE_C_SVCSVM type C-SVC (classification)- 另请参阅:
-
SVMTYPE_NU_SVC
public static final int SVMTYPE_NU_SVCSVM type nu-SVC (classification)- 另请参阅:
-
SVMTYPE_ONE_CLASS_SVM
public static final int SVMTYPE_ONE_CLASS_SVMSVM type one-class SVM (classification)- 另请参阅:
-
SVMTYPE_EPSILON_SVR
public static final int SVMTYPE_EPSILON_SVRSVM type epsilon-SVR (regression)- 另请参阅:
-
SVMTYPE_NU_SVR
public static final int SVMTYPE_NU_SVRSVM type nu-SVR (regression)- 另请参阅:
-
TAGS_SVMTYPE
SVM types -
KERNELTYPE_LINEAR
public static final int KERNELTYPE_LINEARkernel type linear: u'*v- 另请参阅:
-
KERNELTYPE_POLYNOMIAL
public static final int KERNELTYPE_POLYNOMIALkernel type polynomial: (gamma*u'*v + coef0)^degree- 另请参阅:
-
KERNELTYPE_RBF
public static final int KERNELTYPE_RBFkernel type radial basis function: exp(-gamma*|u-v|^2)- 另请参阅:
-
KERNELTYPE_SIGMOID
public static final int KERNELTYPE_SIGMOIDkernel type sigmoid: tanh(gamma*u'*v + coef0)- 另请参阅:
-
TAGS_KERNELTYPE
the different kernel types
-
-
构造器详细资料
-
LibSVM
public LibSVM()
-
-
方法详细资料
-
globalInfo
Returns a string describing classifier- 返回:
- 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.- 指定者:
getTechnicalInformation
在接口中TechnicalInformationHandler
- 返回:
- the technical information about this class
-
listOptions
Returns an enumeration describing the available options.- 指定者:
listOptions
在接口中OptionHandler
- 覆盖:
listOptions
在类中RandomizableClassifier
- 返回:
- an enumeration of all the available options.
-
setOptions
Sets the classifier options Valid options are:-S <int> Set type of SVM (default: 0) 0 = C-SVC 1 = nu-SVC 2 = one-class SVM 3 = epsilon-SVR 4 = nu-SVR
-K <int> Set type of kernel function (default: 2) 0 = linear: u'*v 1 = polynomial: (gamma*u'*v + coef0)^degree 2 = radial basis function: exp(-gamma*|u-v|^2) 3 = sigmoid: tanh(gamma*u'*v + coef0)
-D <int> Set degree in kernel function (default: 3)
-G <double> Set gamma in kernel function (default: 1/k)
-R <double> Set coef0 in kernel function (default: 0)
-C <double> Set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default: 1)
-N <double> Set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default: 0.5)
-Z Turns on normalization of input data (default: off)
-J Turn off nominal to binary conversion. WARNING: use only if your data is all numeric!
-V Turn off missing value replacement. WARNING: use only if your data has no missing values.
-P <double> Set the epsilon in loss function of epsilon-SVR (default: 0.1)
-M <double> Set cache memory size in MB (default: 40)
-E <double> Set tolerance of termination criterion (default: 0.001)
-H Turns the shrinking heuristics off (default: on)
-W <double> Set the parameters C of class i to weight[i]*C, for C-SVC E.g., for a 3-class problem, you could use "1 1 1" for equally weighted classes. (default: 1 for all classes)
-B Generate probability estimates for classification
-seed <num> Random seed (default = 1)
- 指定者:
setOptions
在接口中OptionHandler
- 覆盖:
setOptions
在类中RandomizableClassifier
- 参数:
options
- the options to parse- 抛出:
Exception
- if parsing fails
-
getOptions
Returns the current options- 指定者:
getOptions
在接口中OptionHandler
- 覆盖:
getOptions
在类中RandomizableClassifier
- 返回:
- the current setup
-
isPresent
public static boolean isPresent()returns whether the libsvm classes are present or not, i.e. whether the classes are in the classpath or not- 返回:
- whether the libsvm classes are available
-
setSVMType
Sets type of SVM (default SVMTYPE_C_SVC)- 参数:
value
- the type of the SVM
-
getSVMType
Gets type of SVM- 返回:
- the type of the SVM
-
SVMTypeTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setKernelType
Sets type of kernel function (default KERNELTYPE_RBF)- 参数:
value
- the kernel type
-
getKernelType
Gets type of kernel function- 返回:
- the kernel type
-
kernelTypeTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setDegree
public void setDegree(int value) Sets the degree of the kernel- 参数:
value
- the degree of the kernel
-
getDegree
public int getDegree()Gets the degree of the kernel- 返回:
- the degree of the kernel
-
degreeTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setGamma
public void setGamma(double value) Sets gamma (default = 1/no of attributes)- 参数:
value
- the gamma value
-
getGamma
public double getGamma()Gets gamma- 返回:
- the current gamma
-
gammaTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCoef0
public void setCoef0(double value) Sets coef (default 0)- 参数:
value
- the coef
-
getCoef0
public double getCoef0()Gets coef- 返回:
- the coef
-
coef0TipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNu
public void setNu(double value) Sets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)- 参数:
value
- the new nu value
-
getNu
public double getNu()Gets nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)- 返回:
- the current nu value
-
nuTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCacheSize
public void setCacheSize(double value) Sets cache memory size in MB (default 40)- 参数:
value
- the memory size in MB
-
getCacheSize
public double getCacheSize()Gets cache memory size in MB- 返回:
- the memory size in MB
-
cacheSizeTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setCost
public void setCost(double value) Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)- 参数:
value
- the cost value
-
getCost
public double getCost()Sets the parameter C of C-SVC, epsilon-SVR, and nu-SVR- 返回:
- the cost value
-
costTipText
Returns the tip text for this property- 返回:
- 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)- 参数:
value
- the tolerance
-
getEps
public double getEps()Gets tolerance of termination criterion- 返回:
- the current tolerance
-
epsTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setLoss
public void setLoss(double value) Sets the epsilon in loss function of epsilon-SVR (default 0.1)- 参数:
value
- the loss epsilon
-
getLoss
public double getLoss()Gets the epsilon in loss function of epsilon-SVR- 返回:
- the loss epsilon
-
lossTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setShrinking
public void setShrinking(boolean value) whether to use the shrinking heuristics- 参数:
value
- true uses shrinking
-
getShrinking
public boolean getShrinking()whether to use the shrinking heuristics- 返回:
- true, if shrinking is used
-
shrinkingTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNormalize
public void setNormalize(boolean value) whether to normalize input data- 参数:
value
- whether to normalize the data
-
getNormalize
public boolean getNormalize()whether to normalize input data- 返回:
- true, if the data is normalized
-
normalizeTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
doNotReplaceMissingValuesTipText
Returns the tip text for this property- 返回:
- 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.- 参数:
b
- true if automatic missing values replacement is to be disabled.
-
getDoNotReplaceMissingValues
public boolean getDoNotReplaceMissingValues()Gets whether automatic replacement of missing values is disabled.- 返回:
- true if automatic replacement of missing values is disabled.
-
setWeights
Sets the parameters C of class i to weight[i]*C, for C-SVC (default 1). Blank separated list of doubles.- 参数:
weightsStr
- the weights (doubles, separated by blanks)
-
getWeights
Gets the parameters C of class i to weight[i]*C, for C-SVC (default 1). Blank separated doubles.- 返回:
- the weights (doubles separated by blanks)
-
weightsTipText
Returns the tip text for this property- 返回:
- 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.- 参数:
value
- whether to predict probabilities
-
getProbabilityEstimates
public boolean getProbabilityEstimates()Sets whether to generate probability estimates instead of -1/+1 for classification problems.- 返回:
- true, if probability estimates should be returned
-
probabilityEstimatesTipText
Returns the tip text for this property- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
distributionForInstance
Computes the distribution for a given instance. In case of 1-class classification, 1 is returned at index 0 if libsvm returns 1 and NaN (= missing) if libsvm returns -1.- 覆盖:
distributionForInstance
在类中Classifier
- 参数:
instance
- the instance for which distribution is computed- 返回:
- the distribution
- 抛出:
Exception
- if the distribution can't be computed successfully
-
getCapabilities
Returns default capabilities of the classifier.- 指定者:
getCapabilities
在接口中CapabilitiesHandler
- 覆盖:
getCapabilities
在类中Classifier
- 返回:
- the capabilities of this classifier
- 另请参阅:
-
buildClassifier
builds the classifier- 指定者:
buildClassifier
在类中Classifier
- 参数:
insts
- the training instances- 抛出:
Exception
- if libsvm classes not in classpath or libsvm encountered a problem
-
toString
returns a string representation -
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 覆盖:
getRevision
在类中Classifier
- 返回:
- the revision
-
main
Main method for testing this class.- 参数:
args
- the options
-