MOA 12.03
Real Time Analytics for Data Streams
moa.classifiers.functions.SPegasos Class Reference

Implements the stochastic variant of the Pegasos (Primal Estimated sub-GrAdient SOlver for SVM) method of Shalev-Shwartz et al. More...

Inheritance diagram for moa.classifiers.functions.SPegasos:
Collaboration diagram for moa.classifiers.functions.SPegasos:

List of all members.

Public Member Functions

String getPurposeString ()
 Gets the purpose of this object.
void setLambda (double lambda)
 Set the value of lambda to use.
double getLambda ()
 Get the current value of lambda.
void setLossFunction (int function)
 Set the loss function to use.
int getLossFunction ()
 Get the current loss function.
void reset ()
 Reset the classifier.
void resetLearningImpl ()
 Resets this classifier.
void trainOnInstanceImpl (Instance instance)
 Trains the classifier with the given instance.
double[] getVotesForInstance (Instance inst)
 Calculates the class membership probabilities for the given test instance.
void getModelDescription (StringBuilder result, int indent)
 Returns a string representation of the model.
String toString ()
 Prints out the classifier.
boolean isRandomizable ()
 Gets whether this classifier needs a random seed.

Public Attributes

FloatOption lambdaRegularizationOption
MultiChoiceOption lossFunctionOption

Protected Member Functions

double dloss (double z)
Measurement[] getModelMeasurementsImpl ()
 Gets the current measurements of this classifier.

Static Protected Member Functions

static double dotProd (Instance inst1, double[] weights, int classIndex)

Protected Attributes

double m_lambda = 0.0001
 The regularization parameter.
int m_loss = HINGE
 The current loss function to minimize.
double[] m_weights
 Stores the weights (+ bias in the last element)
double m_t
 Holds the current iteration number.

Static Protected Attributes

static final int HINGE = 0
static final int LOGLOSS = 1

Detailed Description

Implements the stochastic variant of the Pegasos (Primal Estimated sub-GrAdient SOlver for SVM) method of Shalev-Shwartz et al.

(2007). For more information, see

S. Shalev-Shwartz, Y. Singer, N. Srebro: Pegasos: Primal Estimated sub-GrAdient SOlver for SVM. In: 24th International Conference on MachineLearning, 807-814, 2007.

* BibTeX:

 @inproceedings{Shalev-Shwartz2007,
    author = {S. Shalev-Shwartz and Y. Singer and N. Srebro},
    booktitle = {24th International Conference on MachineLearning},
    pages = {807-814},
    title = {Pegasos: Primal Estimated sub-GrAdient SOlver for SVM},
    year = {2007}
 }
 

Definition at line 59 of file SPegasos.java.


Member Function Documentation

double moa.classifiers.functions.SPegasos.dloss ( double  z) [protected]

Definition at line 173 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.trainOnInstanceImpl().

Here is the caller graph for this function:

static double moa.classifiers.functions.SPegasos.dotProd ( Instance  inst1,
double[]  weights,
int  classIndex 
) [static, protected]

Definition at line 149 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.getVotesForInstance(), and moa.classifiers.functions.SPegasos.trainOnInstanceImpl().

Here is the caller graph for this function:

double moa.classifiers.functions.SPegasos.getLambda ( )

Get the current value of lambda.

Returns:
the current value of lambda

Definition at line 119 of file SPegasos.java.

int moa.classifiers.functions.SPegasos.getLossFunction ( )

Get the current loss function.

Returns:
the current loss function.

Definition at line 137 of file SPegasos.java.

void moa.classifiers.functions.SPegasos.getModelDescription ( StringBuilder  out,
int  indent 
) [virtual]

Returns a string representation of the model.

Parameters:
outthe stringbuilder to add the description
indentthe number of characters to indent

Implements moa.classifiers.AbstractClassifier.

Definition at line 295 of file SPegasos.java.

Here is the call graph for this function:

Measurement [] moa.classifiers.functions.SPegasos.getModelMeasurementsImpl ( ) [protected, virtual]

Gets the current measurements of this classifier.



The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.

Returns:
an array of measurements to be used in evaluation tasks

Implements moa.classifiers.AbstractClassifier.

Definition at line 345 of file SPegasos.java.

String moa.classifiers.functions.SPegasos.getPurposeString ( )

Gets the purpose of this object.

Returns:
the string with the purpose of this object

Reimplemented from moa.classifiers.AbstractClassifier.

Definition at line 67 of file SPegasos.java.

double [] moa.classifiers.functions.SPegasos.getVotesForInstance ( Instance  inst)

Calculates the class membership probabilities for the given test instance.

Parameters:
instancethe instance to be classified
Returns:
predicted class probability distribution

Implements moa.classifiers.Classifier.

Definition at line 263 of file SPegasos.java.

Here is the call graph for this function:

boolean moa.classifiers.functions.SPegasos.isRandomizable ( )

Gets whether this classifier needs a random seed.

Examples of methods that needs a random seed are bagging and boosting.

Returns:
true if the classifier needs a random seed.

Implements moa.classifiers.Classifier.

Definition at line 350 of file SPegasos.java.

void moa.classifiers.functions.SPegasos.reset ( )

Reset the classifier.

Definition at line 144 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.resetLearningImpl().

Here is the caller graph for this function:

void moa.classifiers.functions.SPegasos.resetLearningImpl ( ) [virtual]

Resets this classifier.

It must be similar to starting a new classifier from scratch.

The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.

Implements moa.classifiers.AbstractClassifier.

Definition at line 188 of file SPegasos.java.

Here is the call graph for this function:

void moa.classifiers.functions.SPegasos.setLambda ( double  lambda)

Set the value of lambda to use.

Parameters:
lambdathe value of lambda to use

Definition at line 110 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.resetLearningImpl().

Here is the caller graph for this function:

void moa.classifiers.functions.SPegasos.setLossFunction ( int  function)

Set the loss function to use.

Parameters:
functionthe loss function to use.

Definition at line 128 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.resetLearningImpl().

Here is the caller graph for this function:

String moa.classifiers.functions.SPegasos.toString ( )

Prints out the classifier.

Returns:
a description of the classifier as a string

Reimplemented from moa.AbstractMOAObject.

Definition at line 306 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.getModelDescription().

Here is the caller graph for this function:

void moa.classifiers.functions.SPegasos.trainOnInstanceImpl ( Instance  instance) [virtual]

Trains the classifier with the given instance.

Parameters:
instancethe new training instance to include in the model

Implements moa.classifiers.AbstractClassifier.

Definition at line 200 of file SPegasos.java.

Here is the call graph for this function:


Member Data Documentation

Initial value:
 new FloatOption("lambdaRegularization",
            'l', "Lambda regularization parameter .",
            0.0001, 0.00, Integer.MAX_VALUE)

Definition at line 76 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.resetLearningImpl().

Initial value:
 new MultiChoiceOption(
            "lossFunction", 'o', "The loss function to use.", new String[]{
                "HINGE", "LOGLOSS"}, new String[]{
                "Hinge loss (SVM)",
                "Log loss (logistic regression)"}, 0)

Definition at line 89 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.resetLearningImpl().

Holds the current iteration number.

Definition at line 103 of file SPegasos.java.

Referenced by moa.classifiers.functions.SPegasos.reset(), and moa.classifiers.functions.SPegasos.trainOnInstanceImpl().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations