jsat.classifiers.svm.extended
Class CPM
- java.lang.Object
-
- jsat.classifiers.svm.extended.CPM
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, Parameterized
public class CPM extends java.lang.Object implements BinaryScoreClassifier, Classifier, Parameterized
This class implements the Convex Polytope Machine (CPM), which is an extension of the Linear SVM. It is a binary classifier that has training time proportionate to the linear case, but can obtain accuracies closer to that of a kernelized SVM.
Similar to theAMMclassifier, CPM uses multiple linear hyper-planes to create a non-linear classifier. Increasing the number of hyper-planes increases training/prediction time, but also increases the amount of non-linearity the model can tolerate.
While the CPM implements theBinaryScoreClassifierinterface, the CPM decision algorithm does not completely lend itself to producing a natural score in this manner. For this reason you may observe unusual behavior from the CPM if you rely on this interface, compared with other approaches.
See: Kantchelian, A., Tschantz, M. C., Huang, L., Bartlett, P. L., Joseph, A. D., & Tygar, J. D. (2014). Large-margin Convex Polytope Machine. In Proceedings of the 27th International Conference on Neural Information Processing Systems (pp. 3248–3256). Cambridge, MA, USA: MIT Press. Retrieved from here- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description CPM()Creates a new CPM classifier, with default parameters that should work well for most cases.CPM(CPM toCopy)Copy constructorCPM(double lambda)Creates a new CPM classifierCPM(double lambda, int K)Creates a new CPM classifierCPM(double lambda, int K, double entropyThreshold)Creates a new CPM classifierCPM(double lambda, int K, double entropyThreshold, int epochs)Creates a new CPM classifierCPM(int K)Creates a new CPM classifier
-
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.CPMclone()doublegetEntropyThreshold()intgetEpochs()Returns the number of epochs used for trainingintgetK()doublegetLambda()doublegetScore(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.static DistributionguessEntropyThreshold(DataSet d)Provides a distribution of reasonable values for thesetEntropyThreshold(double)parameterstatic DistributionguessLambda(DataSet d)Provides a distribution of reasonable values for theλparametervoidsetEntropyThreshold(double entropyThreshold)Sets the entropy threshold used for training.voidsetEpochs(int epochs)Sets the number of whole iterations through the training set that will be performed for trainingvoidsetK(int K)Sets the number of hyper planes to use when training.voidsetLambda(double lambda)Sets the regularization parameter λ to use.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidtrain(ClassificationDataSet dataSet, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.classifiers.Classifier
train
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
CPM
public CPM()
Creates a new CPM classifier, with default parameters that should work well for most cases.
-
CPM
public CPM(int K)
Creates a new CPM classifier- Parameters:
K- the number of hyper-planes to learn with.
-
CPM
public CPM(double lambda)
Creates a new CPM classifier- Parameters:
lambda- the regularization parameter
-
CPM
public CPM(double lambda, int K)Creates a new CPM classifier- Parameters:
lambda- the regularization parameterK- the number of hyper-planes to learn with.
-
CPM
public CPM(double lambda, int K, double entropyThreshold)Creates a new CPM classifier- Parameters:
lambda- the regularization parameterK- the number of hyper-planes to learn with.entropyThreshold- the parameter that encourages non-linearity to be exploited
-
CPM
public CPM(double lambda, int K, double entropyThreshold, int epochs)Creates a new CPM classifier- Parameters:
lambda- the regularization parameterK- the number of hyper-planes to learn with.entropyThreshold- the parameter that encourages non-linearity to be exploitedepochs- the number of training iterations
-
CPM
public CPM(CPM toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
setEntropyThreshold
public void setEntropyThreshold(double entropyThreshold)
Sets the entropy threshold used for training. It ensures a diversity of hyper-planes are used, where larger values encourage using more of the hyper planes.
This method is adjusted from the paper's definition so that the input can be any non-negative value. It is recommended to try values in the range of [0, 10]- Parameters:
entropyThreshold- the non-negative parameter for hyper-plane diversity
-
getEntropyThreshold
public double getEntropyThreshold()
- Returns:
- the non-negative parameter for hyper-plane diversity
-
setLambda
public void setLambda(double lambda)
Sets the regularization parameter λ to use. Larger values penalize model complexity. This value is adjusted from the form in the original paper so that you do not need to consider the number of epochs explicitly. The effective regularization will be divided by the total number of training updates.- Parameters:
lambda- the regularization parameter value to use, the recommended range range is (0, 104]
-
getLambda
public double getLambda()
- Returns:
- the regularization parameter value
-
setK
public void setK(int K)
Sets the number of hyper planes to use when training. A normal linear model is equivalent to using only 1 hyper plane. The more hyper planes used, the more modeling capacity the algorithm has, but the slower it will run.- Parameters:
K- the number of hyper planes to use.
-
getK
public int getK()
- Returns:
- the number of hyper planes to use.
-
setEpochs
public void setEpochs(int epochs)
Sets the number of whole iterations through the training set that will be performed for training- Parameters:
epochs- the number of whole iterations through the data set
-
getEpochs
public int getEpochs()
Returns the number of epochs used for training- Returns:
- the number of epochs used for training
-
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
-
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
-
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.
-
clone
public CPM clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Overrides:
clonein classjava.lang.Object
-
guessLambda
public static Distribution guessLambda(DataSet d)
Provides a distribution of reasonable values for theλparameter- Parameters:
d- the dataset to get the guess for- Returns:
- the distribution to search this parameter from
-
guessEntropyThreshold
public static Distribution guessEntropyThreshold(DataSet d)
Provides a distribution of reasonable values for thesetEntropyThreshold(double)parameter- Parameters:
d- the dataset to get the guess for- Returns:
- the distribution to search this parameter from
-
-
DataMelt 3.0 © DataMelt by jWork.ORG