public class DoublePegasosSVM extends java.lang.Object implements Classifier<double[]>, java.io.Serializable
Linear SVM classifier on arrays of double using the PEGASOS algorithm.
Pegasos: Primal Estimated sub-GrAdient SOlver for SVM
Shai S. Shwartz, Yoram Singer, Nathan Srebro
In Proceedings of the 24th international conference on Machine learning (2007), pp. 807-814.
Constructor and Description |
---|
DoublePegasosSVM() |
Modifier and Type | Method and Description |
---|---|
DoublePegasosSVM |
copy()
Creates and returns a copy of this object.
|
double |
getB()
Tells the bias b of (w*x -b)
|
double |
getC()
Tells the C hyperparameter, if set, else return 0
|
int |
getK()
Tells the number of samples used by this classifier to compute the subgradient
|
double |
getLambda()
Tells the learning rate of this classifier
|
int |
getT()
Tells the maximum number of iteration of this classifier
|
double |
getT0()
Tells the iteration offset
|
double[] |
getW()
Tells the hyperplane array of this classifier
|
boolean |
isBias()
Tells if this classifier uses a bias term
|
void |
setB(double b)
Sets the bias term
|
void |
setBias(boolean bias)
Sets if the classifier has a bias term
|
void |
setC(double c)
Sets C hyperparameter (automatically converted in lambda)
|
void |
setK(int k)
Sets the number of samples on which to compute the subgradient
|
void |
setLambda(double lambda)
Sets the learning rate lambda
|
void |
setT(int t)
Sets the maximum number of iterations
|
void |
setT0(double t0)
Sets the iteration offset
|
void |
setW(double[] w)
Sets the hyperplane coordinates
|
void |
train(java.util.List<TrainingSample<double[]>> l)
Replace the current training list and train the classifier
|
void |
train(TrainingSample<double[]> t)
Add a single example to the current training set and train the classifier
|
double |
valueOf(double[] e)
Computes the category of the provided example
|
public void train(java.util.List<TrainingSample<double[]>> l)
Classifier
train
in interface Classifier<double[]>
l
- list of training samplespublic void train(TrainingSample<double[]> t)
Classifier
train
in interface Classifier<double[]>
t
- the training samplepublic double valueOf(double[] e)
Classifier
valueOf
in interface Classifier<double[]>
e
- examplepublic int getT()
public void setT(int t)
t
- the maximum number of iterationpublic int getK()
public void setK(int k)
k
- the number of samplespublic double getLambda()
public void setLambda(double lambda)
lambda
- the learning ratepublic double[] getW()
public void setW(double[] w)
w
- the w to setpublic double getB()
public void setB(double b)
b
- the b to setpublic boolean isBias()
public void setBias(boolean bias)
bias
- true for bias, false for non biaspublic double getT0()
public void setT0(double t0)
t0
- the iteration offsetpublic void setC(double c)
c
- public DoublePegasosSVM copy() throws java.lang.CloneNotSupportedException
copy
in interface Classifier<double[]>
java.lang.CloneNotSupportedException
Object.clone()
public double getC()