public class SPegasos extends Classifier implements TechnicalInformationHandler, UpdateableClassifier, OptionHandler
@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}
}
Valid options are:
-L <double> The lambda regularization constant (default = 0.0001)
-E <integer> The number of epochs to perform (batch learning only, default = 500)
-N Don't normalize the data
-M Don't replace missing values
| Modifier and Type | Field and Description |
|---|---|
protected static int |
HINGE |
protected static int |
LOGLOSS |
protected Instances |
m_data
Holds the header of the training data
|
protected boolean |
m_dontNormalize
Turn off normalization of the input data.
|
protected boolean |
m_dontReplaceMissing
Turn off global replacement of missing values.
|
protected int |
m_epochs
The number of epochs to perform (batch learning).
|
protected double |
m_lambda
The regularization parameter
|
protected int |
m_loss
The current loss function to minimize
|
protected NominalToBinary |
m_nominalToBinary
Convert nominal attributes to numerically coded binary ones
|
protected Normalize |
m_normalize
Normalize the training data
|
protected ReplaceMissingValues |
m_replaceMissing
Replace missing values
|
protected double |
m_t
Holds the current iteration number
|
protected double[] |
m_weights
Stores the weights (+ bias in the last element)
|
static Tag[] |
TAGS_SELECTION
Loss functions to choose from
|
m_Debug| Constructor and Description |
|---|
SPegasos() |
| Modifier and Type | Method and Description |
|---|---|
void |
buildClassifier(Instances data)
Method for building the classifier.
|
double[] |
distributionForInstance(Instance inst)
Computes the distribution for a given instance
|
protected double |
dloss(double z) |
String |
dontNormalizeTipText()
Returns the tip text for this property
|
String |
dontReplaceMissingTipText()
Returns the tip text for this property
|
protected static double |
dotProd(Instance inst1,
double[] weights,
int classIndex) |
String |
epochsTipText()
Returns the tip text for this property
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDontNormalize()
Get whether normalization has been turned off.
|
boolean |
getDontReplaceMissing()
Get whether global replacement of missing values has been
disabled.
|
int |
getEpochs()
Get current number of epochs
|
double |
getLambda()
Get the current value of lambda
|
SelectedTag |
getLossFunction()
Get the current loss function.
|
String[] |
getOptions()
Gets the current settings of the classifier.
|
String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
String |
globalInfo()
Returns a string describing classifier
|
String |
lambdaTipText()
Returns the tip text for this property
|
Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
String |
lossFunctionTipText()
Returns the tip text for this property
|
static void |
main(String[] args)
Main method for testing this class.
|
void |
reset()
Reset the classifier.
|
void |
setDontNormalize(boolean m)
Turn normalization off/on.
|
void |
setDontReplaceMissing(boolean m)
Turn global replacement of missing values off/on.
|
void |
setEpochs(int e)
Set the number of epochs to use
|
void |
setLambda(double lambda)
Set the value of lambda to use
|
void |
setLossFunction(SelectedTag function)
Set the loss function to use.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
String |
toString()
Prints out the classifier.
|
void |
updateClassifier(Instance instance)
Updates the classifier with the given instance.
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebugprotected ReplaceMissingValues m_replaceMissing
protected NominalToBinary m_nominalToBinary
protected Normalize m_normalize
protected double m_lambda
protected double[] m_weights
protected double m_t
protected int m_epochs
protected boolean m_dontNormalize
protected boolean m_dontReplaceMissing
protected Instances m_data
protected static final int HINGE
protected static final int LOGLOSS
protected int m_loss
public static final Tag[] TAGS_SELECTION
public Capabilities getCapabilities()
getCapabilities in interface CapabilitiesHandlergetCapabilities in class ClassifierCapabilitiespublic String lambdaTipText()
public void setLambda(double lambda)
lambda - the value of lambda to usepublic double getLambda()
public String epochsTipText()
public void setEpochs(int e)
e - the number of epochs to usepublic int getEpochs()
public void setDontNormalize(boolean m)
m - true if normalization is to be disabled.public boolean getDontNormalize()
public String dontNormalizeTipText()
public void setDontReplaceMissing(boolean m)
m - true if global replacement of missing values is to be
turned off.public boolean getDontReplaceMissing()
public String dontReplaceMissingTipText()
public void setLossFunction(SelectedTag function)
function - the loss function to use.public SelectedTag getLossFunction()
public String lossFunctionTipText()
public Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class Classifierpublic void setOptions(String[] options) throws Exception
-L <double> The lambda regularization constant (default = 0.0001)
-E <integer> The number of epochs to perform (batch learning only, default = 500)
-N Don't normalize the data
-M Don't replace missing values
setOptions in interface OptionHandlersetOptions in class Classifieroptions - the list of options as an array of stringsException - if an option is not supportedpublic String[] getOptions()
getOptions in interface OptionHandlergetOptions in class Classifierpublic String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation in interface TechnicalInformationHandlerpublic void reset()
public void buildClassifier(Instances data) throws Exception
buildClassifier in class Classifierdata - the set of training instances.Exception - if the classifier can't be built successfully.protected static double dotProd(Instance inst1, double[] weights, int classIndex)
protected double dloss(double z)
public void updateClassifier(Instance instance) throws Exception
updateClassifier in interface UpdateableClassifierinstance - the new training instance to include in the modelException - if the instance could not be incorporated in
the model.public double[] distributionForInstance(Instance inst) throws Exception
distributionForInstance in class Classifierinstance - the instance for which distribution is computedException - if the distribution can't be computed successfullypublic String toString()
public String getRevision()
getRevision in interface RevisionHandlergetRevision in class Classifierpublic static void main(String[] args)
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.