jsat.classifiers.linear.kernelized
Class ALMA2K
- java.lang.Object
-
- jsat.classifiers.BaseUpdateableClassifier
-
- jsat.classifiers.linear.kernelized.ALMA2K
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, UpdateableClassifier, Parameterized
public class ALMA2K extends BaseUpdateableClassifier implements BinaryScoreClassifier, Parameterized
Provides a kernelized version of theALMA2algorithm. It is important to note that the number of "support vectors" ALMA may learn is unbounded.
The averaged output of all previous hyperplanes is supported at almost no overhead, and can be turned on by settingsetAveraged(boolean). This information is always collected, and the output can be changed once already learned.
See: Gentile, C. (2002). A New Approximate Maximal Margin Classification Algorithm. The Journal of Machine Learning Research, 2, 213–242. Retrieved from here- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ALMA2K(KernelTrick kernel, double alpha)Creates a new kernelized ALMA2 object
-
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.ALMA2Kclone()doublegetAlpha()Returns the approximation coefficient useddoublegetB()Returns the B value of the ALMA algorithmdoublegetC()KernelTrickgetKernelTrick()Returns the kernel 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.static DistributionguessAlpha(DataSet d)Guesses the distribution to use for the α parameterbooleanisAveraged()Returns whether or not the averaged or last hypothesis is usedvoidsetAlpha(double alpha)Alpha controls the approximation of the large margin formed by ALMA, with larger values causing more updates.voidsetAveraged(boolean averaged)ALMA2K supports taking the averaged output of all previous hypothesis weighted by the number of successful uses of the hypothesis during training.voidsetB(double B)Sets the B variable of the ALMA algorithm, this is set automatically bysetAlpha(double).voidsetC(double C)Sets the C value of the ALMA algorithm.voidsetKernelTrick(KernelTrick K)Sets the kernel to usevoidsetUp(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
-
ALMA2K
public ALMA2K(KernelTrick kernel, double alpha)
Creates a new kernelized ALMA2 object- Parameters:
kernel- the kernel function to usealpha- the alpha parameter of ALMA
-
-
Method Detail
-
clone
public ALMA2K clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Specified by:
clonein interfaceUpdateableClassifier- Specified by:
clonein classBaseUpdateableClassifier
-
setAveraged
public void setAveraged(boolean averaged)
ALMA2K supports taking the averaged output of all previous hypothesis weighted by the number of successful uses of the hypothesis during training. This effectively reduces the variance of the classifier. It has no impact on the training / update phase, only the classification results are impacted.
Unlike most algorithms, this can be changed at any time without issue - even after the algorithm has been trained the type of output (averaged or last) can be switched on the fly.- Parameters:
averaged-trueto use the averaged out,falseto only use the last hypothesis
-
isAveraged
public boolean isAveraged()
Returns whether or not the averaged or last hypothesis is used- Returns:
- whether or not the averaged or last hypothesis is used
-
setKernelTrick
public void setKernelTrick(KernelTrick K)
Sets the kernel to use- Parameters:
K- the kernel to use
-
getKernelTrick
public KernelTrick getKernelTrick()
Returns the kernel in use- Returns:
- the kernel in use
-
setAlpha
public void setAlpha(double alpha)
Alpha controls the approximation of the large margin formed by ALMA, with larger values causing more updates. A value of 1.0 will update only on mistakes, while smaller values update if the error was not far enough away from the margin.
NOTE: Whenever alpha is set, the value ofBwill also be set to an appropriate value. This is not the only possible value that will lead to convergence, and can be set manually after alpha is set to another value.- Parameters:
alpha- the approximation scale in (0.0, 1.0]
-
getAlpha
public double getAlpha()
Returns the approximation coefficient used- Returns:
- the approximation coefficient used
-
setB
public void setB(double B)
Sets the B variable of the ALMA algorithm, this is set automatically bysetAlpha(double).- Parameters:
B- the value for B
-
getB
public double getB()
Returns the B value of the ALMA algorithm- Returns:
- the B value of the ALMA algorithm
-
setC
public void setC(double C)
Sets the C value of the ALMA algorithm. The default value is the one suggested in the paper.- Parameters:
C- the C value of ALMA
-
getC
public double getC()
-
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.
-
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
-
guessAlpha
public static Distribution guessAlpha(DataSet d)
Guesses the distribution to use for the α parameter- Parameters:
d- the dataset to get the guess for- Returns:
- the guess for the α parameter
- See Also:
setAlpha(double)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG