jsat.classifiers.svm
Class SBP
- java.lang.Object
-
- jsat.classifiers.svm.SupportVectorLearner
-
- jsat.classifiers.svm.SBP
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, Parameterized
public class SBP extends SupportVectorLearner implements BinaryScoreClassifier, Parameterized
Implementation of the Stochastic Batch Perceptron (SBP) algorithm. Despite its name, it solves the kernelized SVM problem. Because it is done stochastically, it may not produce Support Vectors that the standard SVM algorithm learns. It can learn at most one SV per iteration. See:
Cotter, A., Shalev-Shwartz, S.,&Srebro, N. (2012). The Kernelized Stochastic Batch Perceptron. International Conference on Machine Learning. Learning. Retrieved from here- 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 SBP(KernelTrick kernel, SupportVectorLearner.CacheMode cacheMode, int iterations, double v)Creates a new SBP SVM learner
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.SBPclone()doublegetBurnIn()intgetIterations()Returns the number of iterations the algorithm will performdoublegetNu()Returns the nu SVM parameterdoublegetScore(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.voidsetBurnIn(double burnIn)Sets the burn in fraction.voidsetIterations(int iterations)Sets the number of iterations to go through.voidsetNu(double nu)The nu parameter for this SVM is not the same as the standard nu-SVM formulation, though it plays a similar role.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.-
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
-
SBP
public SBP(KernelTrick kernel, SupportVectorLearner.CacheMode cacheMode, int iterations, double v)
Creates a new SBP SVM learner- Parameters:
kernel- the kernel to usecacheMode- the type of kernel cache to use
-
-
Method Detail
-
clone
public SBP clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Overrides:
clonein classjava.lang.Object
-
setIterations
public void setIterations(int iterations)
Sets the number of iterations to go through. At most one SV can be learned per iteration. If more iterations are done than there are SVs, it is highly likely that O(n) SVs will be used, making the model very dense. It may take far fewer iterations of the algorithm than there are data points to get good accuracy.- Parameters:
iterations- the number of iterations of the algorithm to perform
-
getIterations
public int getIterations()
Returns the number of iterations the algorithm will perform- Returns:
- the number of iterations the algorithm will perform
-
setNu
public void setNu(double nu)
The nu parameter for this SVM is not the same as the standard nu-SVM formulation, though it plays a similar role. It must be in the range (0, 1), where small values indicate a linearly separable problem (in the kernel space), and large values mean the problem is less separable. If the value is too small for the problem, the SVM may fail to converge or produce good results.- Parameters:
nu- the value between (0, 1)
-
getNu
public double getNu()
Returns the nu SVM parameter- Returns:
- the nu SVM parameter
-
setBurnIn
public void setBurnIn(double burnIn)
Sets the burn in fraction. SBP averages the intermediate solutions from each step as the final solution. The intermediate steps of SBP are highly correlated, and the begging solutions are usually not as meaningful toward the converged solution. To overcome this issue a certain fraction of the iterations are not averaged into the final solution, making them the "burn in" fraction. A value of 0.25 would then be ignoring the initial 25% of solutions.- Parameters:
burnIn- the ratio int [0, 1) initial solutions to ignore
-
getBurnIn
public double getBurnIn()
- Returns:
- the burn in fraction
-
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, 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)
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
-
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- Returns:
- true if the model supports weighted data, false otherwise
-
-
DataMelt 3.0 © DataMelt by jWork.ORG