jsat.classifiers.linear.kernelized
Class Projectron
- java.lang.Object
-
- jsat.classifiers.BaseUpdateableClassifier
-
- jsat.classifiers.linear.kernelized.Projectron
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, UpdateableClassifier, Parameterized
public class Projectron extends BaseUpdateableClassifier implements BinaryScoreClassifier, Parameterized
An implementation of the Projectron and Projectrion++ algorithms. These are a kernelized extensions of thePerceptronthat bound the number of support vectors used, with the latter incorporating some similarities fromPassiveAggressive.
Unlike many other bounded kernel learners, the number of support vectors is not specified by the user. This value is controlled by a sparsity parametersetEta(double).
See:- Orabona, F., Keshet, J.,&Caputo, B. (2008). The Projectron: a bounded kernel-based Perceptron. Proceedings of the 25th international conference on Machine learning - ICML ’08 (pp. 720–727). New York, New York, USA: ACM Press. doi:10.1145/1390156.1390247
- Orabona, F., Keshet, J.,&Caputo, B. (2009). Bounded Kernel-Based Online Learning. The Journal of Machine Learning Research, 10, 2643–2666.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Projectron(KernelTrick k)Creates a new Projectron++ learnerProjectron(KernelTrick k, double eta)Creates a new Projectron++ learnerProjectron(KernelTrick k, double eta, boolean useMarginUpdates)Creates a new Projectron 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.Projectronclone()doublegetEta()Returns the sparsity parameter valueKernelTrickgetKernel()Returns the kernel trick in usedoublegetScore(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.booleanisUseMarginUpdates()Returnstrueif margin errors can cause updates,falseif not.voidsetEta(double eta)Sets the η parameter which controls the sparsity of the Projection solution.voidsetKernel(KernelTrick k)Sets the kernel trick to be usedvoidsetUp(CategoricalData[] categoricalAttributes, int numericAttributes, CategoricalData predicting)Prepares the classifier to begin learning from itsUpdateableClassifier.update(jsat.classifiers.DataPoint, int)method.voidsetUseMarginUpdates(boolean useMarginUpdates)Sets whether or not projection updates will be performed for margin errors.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidupdate(DataPoint dataPoint, int targetClass)Updates the classifier by giving it a new data point to learn from.-
Methods inherited from class jsat.classifiers.BaseUpdateableClassifier
getEpochs, setEpochs, train, train, trainEpochs
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.classifiers.Classifier
train, train
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
Projectron
public Projectron(KernelTrick k)
Creates a new Projectron++ learner- Parameters:
k- the kernel to use
-
Projectron
public Projectron(KernelTrick k, double eta)
Creates a new Projectron++ learner- Parameters:
k- the kernel to useeta- the sparsity parameter
-
Projectron
public Projectron(KernelTrick k, double eta, boolean useMarginUpdates)
Creates a new Projectron learner- Parameters:
k- the kernel to useeta- the sparsity parameteruseMarginUpdates- whether or not to perform projection updates on margin errors
-
-
Method Detail
-
setKernel
public void setKernel(KernelTrick k)
Sets the kernel trick to be used- Parameters:
k- the kernel trick to be use
-
getKernel
public KernelTrick getKernel()
Returns the kernel trick in use- Returns:
- the kernel trick in use
-
setEta
public void setEta(double eta)
Sets the η parameter which controls the sparsity of the Projection solution. Larger values result in greater sparsity, at the potential loss of accuracy. If set to 0 andsetUseMarginUpdates(boolean)isfalse, the Projectron degenerates into the standard kernelized Perceptron.- Parameters:
eta- the sparsity parameter in [0, Infinity)
-
getEta
public double getEta()
Returns the sparsity parameter value- Returns:
- the sparsity parameter value
-
setUseMarginUpdates
public void setUseMarginUpdates(boolean useMarginUpdates)
Sets whether or not projection updates will be performed for margin errors. Iftrue, this behaves as the Projectrion++ algorithm. Iffalse, the behavior is equal to the standard Projectron.- Parameters:
useMarginUpdates-trueto perform updates on margin errors
-
isUseMarginUpdates
public boolean isUseMarginUpdates()
Returnstrueif margin errors can cause updates,falseif not.- Returns:
trueif margin errors can cause updates,falseif not.
-
clone
public Projectron clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Specified by:
clonein interfaceUpdateableClassifier- Specified by:
clonein classBaseUpdateableClassifier
-
setUp
public void setUp(CategoricalData[] categoricalAttributes, int numericAttributes, CategoricalData predicting)
Description copied from interface:UpdateableClassifierPrepares the classifier to begin learning from itsUpdateableClassifier.update(jsat.classifiers.DataPoint, int)method.- Specified by:
setUpin interfaceUpdateableClassifier- Parameters:
categoricalAttributes- an array containing the categorical attributes that will be in each data pointnumericAttributes- the number of numeric attributes that will be in each data pointpredicting- the information for the target class that will be predicted
-
update
public void update(DataPoint dataPoint, int targetClass)
Description copied from interface:UpdateableClassifierUpdates the classifier by giving it a new data point to learn from.- Specified by:
updatein interfaceUpdateableClassifier- Parameters:
dataPoint- the data point to learntargetClass- the target class of the data point
-
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.
-
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
-
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
-
-
DataMelt 3.0 © DataMelt by jWork.ORG