jsat.classifiers.linear.kernelized
Class Forgetron
- java.lang.Object
-
- jsat.classifiers.BaseUpdateableClassifier
-
- jsat.classifiers.linear.kernelized.Forgetron
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, UpdateableClassifier, Parameterized
public class Forgetron extends BaseUpdateableClassifier implements BinaryScoreClassifier, Parameterized
Implementation of the first two Forgetron algorithms. The Forgetron is a kernelized version of thePerceptronthat maintains a fixed sized buffer of data instances that it uses to form its decision boundary.
See:
Dekel, O., Shalev-Shwartz, S.,&Singer, Y. (2008). The Forgetron: A kernel-based perceptron on a fixed budget. SIAM Journal on Computing, 37(5), 1342–1372.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Forgetron(KernelTrick kernel, int budget)Creates a new Forgetron
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.Forgetronclone()intgetBudget()Returns the current budgetKernelTrickgetKernelTrick()Returns the current kernel trickdoublegetScore(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.booleanisSelfTuned()voidsetBudget(int budget)Sets the new budget, which is the maximum number of data points the Forgetron can use to form its decision boundary.voidsetKernelTrick(KernelTrick K)Sets the kernel trick to usevoidsetSelfTurned(boolean selfTurned)Sets whether or not the self-tuned variant of the Forgetron is used, the default istruevoidsetUp(CategoricalData[] categoricalAttributes, int numericAttributes, CategoricalData predicting)Prepares the classifier to begin learning from itsUpdateableClassifier.update(jsat.classifiers.DataPoint, int)method.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
-
Forgetron
public Forgetron(KernelTrick kernel, int budget)
Creates a new Forgetron- Parameters:
kernel- the kernel function to usebudget- the maximum number of data points to use
-
-
Method Detail
-
setSelfTurned
public void setSelfTurned(boolean selfTurned)
Sets whether or not the self-tuned variant of the Forgetron is used, the default istrue- Parameters:
selfTurned-trueto use the self-tuned variance,falseotherwise.
-
isSelfTuned
public boolean isSelfTuned()
- Returns:
trueif the self-tuned variant is used,falseotherwise.
-
setBudget
public void setBudget(int budget)
Sets the new budget, which is the maximum number of data points the Forgetron can use to form its decision boundary.- Parameters:
budget- the maximum number of data points to use
-
getBudget
public int getBudget()
Returns the current budget- Returns:
- the current budget
-
setKernelTrick
public void setKernelTrick(KernelTrick K)
Sets the kernel trick to use- Parameters:
K- the kernel trick to use
-
getKernelTrick
public KernelTrick getKernelTrick()
Returns the current kernel trick- Returns:
- the current kernel trick
-
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
-
clone
public Forgetron 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
-
-
DataMelt 3.0 © DataMelt by jWork.ORG