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

Implements stochastic gradient descent for learning various linear models (binary class SVM, binary class logistic regression and linear regression). More...

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

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 setLearningRate (double lr)
 Set the learning rate.
double getLearningRate ()
 Get the learning rate.
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
FloatOption learningRateOption
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.
double m_learningRate = 0.01
 The learning rate.
double[] m_weights
 Stores the weights (+ bias in the last element)
double m_t
 Holds the current iteration number.
double m_numInstances
 The number of training instances.
int m_loss = HINGE
 The current loss function to minimize.

Static Protected Attributes

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

Detailed Description

Implements stochastic gradient descent for learning various linear models (binary class SVM, binary class logistic regression and linear regression).

Definition at line 44 of file SGD.java.


Member Function Documentation

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

Definition at line 155 of file SGD.java.

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

Here is the caller graph for this function:

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

Definition at line 174 of file SGD.java.

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

Here is the caller graph for this function:

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

Get the current value of lambda.

Returns:
the current value of lambda

Definition at line 107 of file SGD.java.

double moa.classifiers.functions.SGD.getLearningRate ( )

Get the learning rate.

Returns:
the learning rate

Definition at line 143 of file SGD.java.

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

Get the current loss function.

Returns:
the current loss function.

Definition at line 125 of file SGD.java.

void moa.classifiers.functions.SGD.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 312 of file SGD.java.

Here is the call graph for this function:

Measurement [] moa.classifiers.functions.SGD.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 365 of file SGD.java.

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

Gets the purpose of this object.

Returns:
the string with the purpose of this object

Reimplemented from moa.classifiers.AbstractClassifier.

Definition at line 50 of file SGD.java.

double [] moa.classifiers.functions.SGD.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 274 of file SGD.java.

Here is the call graph for this function:

boolean moa.classifiers.functions.SGD.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 370 of file SGD.java.

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

Reset the classifier.

Definition at line 150 of file SGD.java.

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

Here is the caller graph for this function:

void moa.classifiers.functions.SGD.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 199 of file SGD.java.

Here is the call graph for this function:

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

Set the value of lambda to use.

Parameters:
lambdathe value of lambda to use

Definition at line 98 of file SGD.java.

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

Here is the caller graph for this function:

void moa.classifiers.functions.SGD.setLearningRate ( double  lr)

Set the learning rate.

Parameters:
lrthe learning rate to use.

Definition at line 134 of file SGD.java.

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

Here is the caller graph for this function:

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

Set the loss function to use.

Parameters:
functionthe loss function to use.

Definition at line 116 of file SGD.java.

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

Here is the caller graph for this function:

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

Prints out the classifier.

Returns:
a description of the classifier as a string

Reimplemented from moa.AbstractMOAObject.

Definition at line 322 of file SGD.java.

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

Here is the caller graph for this function:

void moa.classifiers.functions.SGD.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 212 of file SGD.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 57 of file SGD.java.

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

Initial value:
 new FloatOption("learningRate",
            'r', "Learning rate parameter.",
            0.0001, 0.00, Integer.MAX_VALUE)

Definition at line 64 of file SGD.java.

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

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

Definition at line 86 of file SGD.java.

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

The number of training instances.

Definition at line 75 of file SGD.java.

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

Holds the current iteration number.

Definition at line 72 of file SGD.java.

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

final int moa.classifiers.functions.SGD.SQUAREDLOSS = 2 [static, protected]

Definition at line 81 of file SGD.java.


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