jsat.classifiers.svm
Class PlattSMO
- java.lang.Object
-
- jsat.classifiers.svm.SupportVectorLearner
-
- jsat.classifiers.svm.PlattSMO
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, WarmClassifier, Parameterized, Regressor, WarmRegressor
public class PlattSMO extends SupportVectorLearner implements BinaryScoreClassifier, WarmRegressor, Parameterized, WarmClassifier
An implementation of SVMs using Platt's Sequential Minimum Optimization (SMO) for both Classification and Regression problems.
This algorithm can be warm started for classification problems by any algorithm implementing theBinaryScoreClassifierinterface. For regression any algorithm can be used as a warms start. For best results, warm starts should be from algorithms that will have a similar solution to PlattSMO.
See:
- Platt, J. C. (1998). Sequential Minimal Optimization: A Fast Algorithm for Training Support Vector Machines. Advances in kernel methods (pp. 185 – 208). Retrieved from here
- Keerthi, S. S., Shevade, S. K., Bhattacharyya, C.,&Murthy, K. R. K. (2001). Improvements to Platt’s SMO Algorithm for SVM Classifier Design . Neural Computation, 13(3), 637–649. doi:10.1162/089976601300014493
- Smola, A. J.,&Schölkopf, B. (2004). A tutorial on support vector regression. Statistics and Computing, 14(3), 199–222. doi:10.1023/B:STCO.0000035301.49549.88
- Shevade, S. K., Keerthi, S. S., Bhattacharyya, C.,&Murthy, K. K. (1999) . Improvements to the SMO algorithm for SVM regression. Control D ivision, Dept. of Mechanical Engineering CD-99–16. Control Division, Dept. of Mechanical Engineering. doi:10.1109/72.870050
- Shevade, S. K., Keerthi, S. S., Bhattacharyya, C.,&Murthy, K. K. (2000) . Improvements to the SMO algorithm for SVM regression. IEEE transactions on neural networks / a publication of the IEEE Neural Networks Council, 11(5), 1188–93. doi:10.1109/72.870050
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsat.classifiers.svm.SupportVectorLearner
SupportVectorLearner.CacheMode
-
-
Constructor Summary
Constructors Constructor and Description PlattSMO()Creates a new SVM object with aLinearKernelthat uses no cache mode.PlattSMO(KernelTrick kf)Creates a new SVM object that uses no cache mode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.PlattSMOclone()doublegetC()Returns the soft margin complexity parameter of the SVMdoublegetEpsilon()Returns the epsilon insensitive loss valueintgetMaxIterations()Returns the maximum number of iterationsdoublegetScore(DataPoint dp)Returns the numeric score for predicting a class of a given data point, where the sign of the value indicates which class the data point is predicted to belong to.doublegetTolerance()Returns the solution tolerancestatic DistributionguessC(DataSet d)Guess the distribution to use for the regularization termCin a SVM.booleanisModificationOne()Returns true if modification one is in usedoubleregress(DataPoint data)voidsetC(double C)Sets the complexity parameter of SVM.voidsetEpsilon(double epsilon)Sets the epsilon for the epsilon insensitive loss when performing regression.voidsetMaxIterations(int maxIterations)Sets the maximum number of iterations to perform of the training loop.voidsetModificationOne(boolean modificationOne)Sets where or not modification one or two should be used when training.voidsetTolerance(double tolerance)Sets the tolerance for the solution.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidtrain(ClassificationDataSet dataSet)Trains the classifier and constructs a model for classification using the given data set.voidtrain(ClassificationDataSet dataSet, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.voidtrain(ClassificationDataSet dataSet, Classifier warmSolution)Trains the classifier and constructs a model for classification using the given data set.voidtrain(ClassificationDataSet dataSet, Classifier warmSolution, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.voidtrain(RegressionDataSet dataSet)voidtrain(RegressionDataSet dataSet, boolean parallel)voidtrain(RegressionDataSet dataSet, Regressor warmSolution)Trains the regressor and constructs a model for regression using the given data set.voidtrain(RegressionDataSet dataSet, Regressor warmSolution, boolean parallel)Trains the regressor and constructs a model for regression using the given data set.booleanwarmFromSameDataOnly()Some models can only be warm started from a solution trained on the exact same data set as the model it is warm starting from.-
Methods inherited from class jsat.classifiers.svm.SupportVectorLearner
getCacheMode, getCacheValue, getKernel, setCacheMode, setCacheSize, setCacheValue, setKernel
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
PlattSMO
public PlattSMO()
Creates a new SVM object with aLinearKernelthat uses no cache mode.
-
PlattSMO
public PlattSMO(KernelTrick kf)
Creates a new SVM object that uses no cache mode.- Parameters:
kf- the kernel trick to use
-
-
Method Detail
-
classify
public CategoricalResults classify(DataPoint data)
Description copied from interface:ClassifierPerforms classification on the given data point.- Specified by:
classifyin interfaceClassifier- Parameters:
data- the data point to classify- Returns:
- the results of the classification.
-
getScore
public double getScore(DataPoint dp)
Description copied from interface:BinaryScoreClassifierReturns the numeric score for predicting a class of a given data point, where the sign of the value indicates which class the data point is predicted to belong to.- Specified by:
getScorein interfaceBinaryScoreClassifier- Parameters:
dp- the data point to predict the class label of- Returns:
- the score for the given data point
-
train
public void train(ClassificationDataSet dataSet, Classifier warmSolution, boolean parallel)
Description copied from interface:WarmClassifierTrains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceWarmClassifier- Parameters:
dataSet- the data set to train onwarmSolution- the solution to use to warm start this modelparallel-trueif the training should be done using multiple-cores,falsefor single threaded.
-
train
public void train(ClassificationDataSet dataSet, boolean parallel)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train onparallel-trueif multiple threads should be used to train the model.falseif it should be done in a single threaded manner.
-
train
public void train(ClassificationDataSet dataSet, Classifier warmSolution)
Description copied from interface:WarmClassifierTrains the classifier and constructs a model for classification using the given data set.- Specified by:
trainin interfaceWarmClassifier- Parameters:
dataSet- the data set to train onwarmSolution- the solution to use to warm start this model
-
train
public void train(ClassificationDataSet dataSet)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train on
-
clone
public PlattSMO clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Specified by:
clonein interfaceRegressor- Overrides:
clonein classjava.lang.Object
-
supportsWeightedData
public boolean supportsWeightedData()
Description copied from interface:ClassifierIndicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.- Specified by:
supportsWeightedDatain interfaceClassifier- Specified by:
supportsWeightedDatain interfaceRegressor- Returns:
- true if the model supports weighted data, false otherwise
-
setC
public void setC(double C)
Sets the complexity parameter of SVM. The larger the C value the harder the margin SVM will attempt to find. Lower values of C allow for more misclassification errors.- Parameters:
C- the soft margin parameter
-
getC
public double getC()
Returns the soft margin complexity parameter of the SVM- Returns:
- the complexity parameter of the SVM
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations to perform of the training loop. This is important for cases with a C value that is to large for a non linear problem, which can result in SVM failing to converge.- Parameters:
maxIterations- the maximum number of main iteration loops
-
getMaxIterations
public int getMaxIterations()
Returns the maximum number of iterations- Returns:
- the maximum number of iterations
-
setModificationOne
public void setModificationOne(boolean modificationOne)
Sets where or not modification one or two should be used when training. Modification two is more aggressive, but often results in less kernel evaluations.- Parameters:
modificationOne-trueto us modificaiotn one,falseto use modification two.
-
isModificationOne
public boolean isModificationOne()
Returns true if modification one is in use- Returns:
- true if modification one is in use
-
setTolerance
public void setTolerance(double tolerance)
Sets the tolerance for the solution. Higher values converge to worse solutions, but do so faster- Parameters:
tolerance- the tolerance for the solution
-
getTolerance
public double getTolerance()
Returns the solution tolerance- Returns:
- the solution tolerance
-
train
public void train(RegressionDataSet dataSet, boolean parallel)
-
setEpsilon
public void setEpsilon(double epsilon)
Sets the epsilon for the epsilon insensitive loss when performing regression. This variable has no impact during classification problems. For regression problems, any predicated value that is within the epsilon of the target will be treated as "correct". Increasing epsilon usually decreases the number of support vectors, but may reduce the accuracy of the model- Parameters:
epsilon- the positive value for the acceptable error when doing regression
-
getEpsilon
public double getEpsilon()
Returns the epsilon insensitive loss value- Returns:
- the epsilon insensitive loss value
-
train
public void train(RegressionDataSet dataSet, Regressor warmSolution, boolean parallel)
Description copied from interface:WarmRegressorTrains the regressor and constructs a model for regression using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceWarmRegressor- Parameters:
dataSet- the data set to train onwarmSolution- the solution to use to warm start this modelparallel-trueif the training should be done using multiple-cores,falsefor single threaded.
-
train
public void train(RegressionDataSet dataSet)
-
train
public void train(RegressionDataSet dataSet, Regressor warmSolution)
Description copied from interface:WarmRegressorTrains the regressor and constructs a model for regression using the given data set.- Specified by:
trainin interfaceWarmRegressor- Parameters:
dataSet- the data set to train onwarmSolution- the solution to use to warm start this model
-
warmFromSameDataOnly
public boolean warmFromSameDataOnly()
Description copied from interface:WarmRegressorSome models can only be warm started from a solution trained on the exact same data set as the model it is warm starting from. If this is the casetruewill be returned. The behavior for training on a different data set when this is defined is undefined. It may cause an error, or it may cause the algorithm to take longer or reach a worse solution.
Whentrue, it is important that the data set be unaltered - this includes mutating the values stored or re-arranging the data points within the data set.- Specified by:
warmFromSameDataOnlyin interfaceWarmClassifier- Specified by:
warmFromSameDataOnlyin interfaceWarmRegressor- Returns:
trueif the algorithm can only be warm started from the model trained on the exact same data set.
-
guessC
public static Distribution guessC(DataSet d)
Guess the distribution to use for the regularization termCin a SVM.- Parameters:
d- the data set to get the guess for- Returns:
- the guess for the C parameter in the SVM
-
-
DataMelt 3.0 © DataMelt by jWork.ORG