jsat.classifiers.linear.kernelized
Class BOGD
- java.lang.Object
-
- jsat.classifiers.BaseUpdateableClassifier
-
- jsat.classifiers.linear.kernelized.BOGD
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, UpdateableClassifier, Parameterized
public class BOGD extends BaseUpdateableClassifier implements BinaryScoreClassifier, Parameterized
Bounded Online Gradient Descent (BOGD) is a kernel learning algorithm that uses a bounded number of support vectors. Once the maximum number of support vectors is reached, old vectors are dropped either in a uniform random fashion, or weighted by the kernel function and the current coefficient for the vector. The later is the default method and is referred to as BOGD++.
See: Zhao, P., Wang, J., Wu, P., Jin, R.,&Hoi, S. C. H. (2012). Fast Bounded Online Gradient Descent Algorithms for Scalable Kernel-Based Online Learning. In Proceedings of the 29th International Conference on Machine Learning (pp. 169–176). Learning; Machine Learning. Retrieved from here- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description BOGD(BOGD toCopy)Copy constructorBOGD(KernelTrick k, int budget, double eta, double reg, double maxCoeff)Creates a new BOGD++ learner using theHingeLossBOGD(KernelTrick k, int budget, double eta, double reg, double maxCoeff, LossC lossC)Creates a new BOGD++ learner
-
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.BOGDclone()intgetBudget()Returns the maximum number of allowed support vectorsdoublegetEta()Returns the learning rate in useKernelTrickgetKernel()Returns the kernel to usedoublegetMaxCoeff()Returns the maximum allowed value for any support vectordoublegetRegularization()Returns the regularization parameter useddoublegetScore(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 DistributionguessEta(DataSet d)Guesses the distribution to use for the η parameterstatic DistributionguessMaxCoeff(DataSet d)Guesses the distribution to use for the MaxCoeff parameterstatic DistributionguessRegularization(DataSet d)Guesses the distribution to use for the Regularization parameterbooleanisUniformSampling()Returnstrueis uniform sampling is in use, orfalseif the BOGD++ sampling procedure is in usevoidsetBudget(int budget)Sets the budget for support vectorsvoidsetEta(double eta)Sets the learning rate to use for training.voidsetKernel(KernelTrick k)Sets the kernel to usevoidsetMaxCoeff(double maxCoeff)Sets the maximum allowed value for any support vector allowed.voidsetRegularization(double regularization)Sets the regularization parameter used for training.voidsetUniformSampling(boolean uniformSampling)Sets whether or not support vectors should be removed by uniform sampling or not.voidsetUp(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
-
BOGD
public BOGD(KernelTrick k, int budget, double eta, double reg, double maxCoeff)
Creates a new BOGD++ learner using theHingeLoss- Parameters:
k- the kernel trick to usebudget- the budget for support vectors to alloweta- the learning rate to usereg- the regularization parametermaxCoeff- the maximum support vector coefficient to allow
-
BOGD
public BOGD(KernelTrick k, int budget, double eta, double reg, double maxCoeff, LossC lossC)
Creates a new BOGD++ learner- Parameters:
k- the kernel trick to usebudget- the budget for support vectors to alloweta- the learning rate to usereg- the regularization parametermaxCoeff- the maximum support vector coefficient to allowlossC- the loss function to use
-
BOGD
public BOGD(BOGD toCopy)
Copy constructor- Parameters:
toCopy- the object to make a copy of
-
-
Method Detail
-
setRegularization
public void setRegularization(double regularization)
Sets the regularization parameter used for training. The original paper suggests values in the range 2x/T2 for x ∈ {-3, -2, -1, 0, 1, 2, 3} where T is the number of data instances that will be trained on- Parameters:
regularization- the positive regularization parameter to use.
-
getRegularization
public double getRegularization()
Returns the regularization parameter used- Returns:
- the regularization parameter used
-
setEta
public void setEta(double eta)
Sets the learning rate to use for training. The original paper suggests values in the range 2x for x ∈ {-3, -2, -1, 0, 1, 2, 3}- Parameters:
eta- the positive learning rate to use
-
getEta
public double getEta()
Returns the learning rate in use- Returns:
- the learning rate in use
-
setMaxCoeff
public void setMaxCoeff(double maxCoeff)
Sets the maximum allowed value for any support vector allowed. The original paper suggests values in the range 2x for x ∈ {0, 1, 2, 3, 4}- Parameters:
maxCoeff- the maximum value for any support vector
-
getMaxCoeff
public double getMaxCoeff()
Returns the maximum allowed value for any support vector- Returns:
- the maximum allowed value for any support vector
-
setBudget
public void setBudget(int budget)
Sets the budget for support vectors- Parameters:
budget- the allowed budget for support vectors
-
getBudget
public int getBudget()
Returns the maximum number of allowed support vectors- Returns:
- the maximum number of allowed support vectors
-
setKernel
public void setKernel(KernelTrick k)
Sets the kernel to use- Parameters:
k- the kernel to use
-
getKernel
public KernelTrick getKernel()
Returns the kernel to use- Returns:
- the kernel to use
-
setUniformSampling
public void setUniformSampling(boolean uniformSampling)
Sets whether or not support vectors should be removed by uniform sampling or not. The default isfalse, which corresponds to BOGD++.- Parameters:
uniformSampling-trueto use uniform sampling,falseotherwise.
-
isUniformSampling
public boolean isUniformSampling()
Returnstrueis uniform sampling is in use, orfalseif the BOGD++ sampling procedure is in use- Returns:
trueis uniform sampling is in use, orfalseif the BOGD++ sampling procedure is in use
-
clone
public BOGD 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
-
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
-
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
-
guessRegularization
public static Distribution guessRegularization(DataSet d)
Guesses the distribution to use for the Regularization parameter- Parameters:
d- the dataset to get the guess for- Returns:
- the guess for the Regularization parameter
- See Also:
setRegularization(double)
-
guessEta
public static Distribution guessEta(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:
setEta(double)
-
guessMaxCoeff
public static Distribution guessMaxCoeff(DataSet d)
Guesses the distribution to use for the MaxCoeff parameter- Parameters:
d- the dataset to get the guess for- Returns:
- the guess for the MaxCoeff parameter
- See Also:
(double)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG