public class PegasosK extends SupportVectorLearner implements BinaryScoreClassifier, Parameterized
Pegasos
algorithm for SVMs.
Unlike standard SVM algorithms, this one relies on randomness and has no
guarantee to reach the optimal solution, however it is very fast to train.
Each iteration of the algorithm randomly selects one datapoint to potentially
update the coefficient of. SupportVectorLearner.CacheMode
accelCache, alphas, cacheEvictions, evalCount, vecs
Constructor and Description |
---|
PegasosK(double regularization,
int iterations,
KernelTrick kernel)
Creates a new kernelized Pegasos SVM solver
|
PegasosK(double regularization,
int iterations,
KernelTrick kernel,
SupportVectorLearner.CacheMode cacheMode)
Creates a new kernelized Pegasos SVM solver
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
PegasosK |
clone() |
int |
getIterations()
Returns the number of iterations used during training
|
Parameter |
getParameter(String paramName)
Returns the parameter with the given name.
|
List<Parameter> |
getParameters()
Returns the list of parameters that can be altered for this learner.
|
double |
getRegularization()
Returns the amount of regularization used
|
double |
getScore(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.
|
void |
setIterations(int iterations)
Sets the number of iterations of the algorithm to perform.
|
void |
setRegularization(double regularization)
Sets the amount of regularization to apply.
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
void |
trainC(ClassificationDataSet dataSet)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
ExecutorService threadPool)
Trains the classifier and constructs a model for classification using the
given data set.
|
accessingRow, getCacheMode, getCacheValue, getKernel, k, kEval, kEval, kEvalSum, setAlphas, setCacheMode, setCacheSize, setCacheValue, setKernel, sparsify
public PegasosK(double regularization, int iterations, KernelTrick kernel)
regularization
- the amount of regularization to apply, normally a very small positive valueiterations
- the number of update iterations to performkernel
- the kernel to usepublic PegasosK(double regularization, int iterations, KernelTrick kernel, SupportVectorLearner.CacheMode cacheMode)
regularization
- the amount of regularization to apply, normally a very small positive valueiterations
- the number of update iterations to performkernel
- the kernel to usecacheMode
- what type of kernel caching to usepublic void setIterations(int iterations)
iterations
- the number of learning iterations to performpublic int getIterations()
public void setRegularization(double regularization)
regularization
- the amount of regularization to applypublic double getRegularization()
public PegasosK clone()
clone
in interface BinaryScoreClassifier
clone
in interface Classifier
clone
in class Object
public CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic double getScore(DataPoint dp)
BinaryScoreClassifier
getScore
in interface BinaryScoreClassifier
dp
- the data point to predict the class label ofpublic void trainC(ClassificationDataSet dataSet, ExecutorService threadPool)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
public List<Parameter> getParameters()
Parameterized
getParameters
in interface Parameterized
public Parameter getParameter(String paramName)
Parameterized
getParameter
in interface Parameterized
paramName
- the name of the parameter to obtainCopyright © 2017. All rights reserved.