public class SPA extends BaseUpdateableClassifier implements Parameterized, SimpleWeightVectorModel
PassiveAggressive
. It works in the same philosophy, and can obtain
better multi class accuracy then PA used with a meta learner. aggressiveness parameter
. biast term
is not used.
Constructor and Description |
---|
SPA()
Creates a new Passive Aggressive learner that does 10 epochs and uses
PA2.
|
SPA(int epochs,
PassiveAggressive.Mode mode)
Creates a new Passive Aggressive learner
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
SPA |
clone() |
double |
getBias(int index)
Returns the bias term used with the weight vector for the given class
index.
|
double |
getC()
Returns the aggressiveness parameter
|
PassiveAggressive.Mode |
getMode()
Returns which version of the PA update is used
|
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.
|
Vec |
getRawWeight(int index)
Returns the raw weight vector associated with the given class index.
|
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C in Support PassiveAggressive. |
boolean |
isUseBias()
Returns true if an implicit bias term will be added, false otherwise
|
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
void |
setC(double C)
Set the aggressiveness parameter.
|
void |
setMode(PassiveAggressive.Mode mode)
Sets which version of the PA update is used.
|
void |
setUp(CategoricalData[] categoricalAttributes,
int numericAttributes,
CategoricalData predicting)
Prepares the classifier to begin learning from its
UpdateableClassifier.update(jsat.classifiers.DataPoint, int) method. |
void |
setUseBias(boolean useBias)
Sets whether or not the implementation will use an implicit bias term
appended to the inputs or not.
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
void |
update(DataPoint dataPoint,
int targetClass)
Updates the classifier by giving it a new data point to learn from.
|
getEpochs, setEpochs, trainC, trainC, trainEpochs
public SPA()
public SPA(int epochs, PassiveAggressive.Mode mode)
epochs
- the number of training epochs to use during batch trainingmode
- which version of the update to performpublic void setUseBias(boolean useBias)
useBias
- true
to add an implicit bias term, false
to use the data as givenpublic boolean isUseBias()
public void setC(double C)
PassiveAggressive.Mode.PA
.C
- the positive aggressiveness parameterpublic double getC()
public void setMode(PassiveAggressive.Mode mode)
mode
- which PA update style to performpublic PassiveAggressive.Mode getMode()
public Vec getRawWeight(int index)
SimpleWeightVectorModel
ConstantVector
object may be returned. index = 0
should be usedgetRawWeight
in interface SimpleWeightVectorModel
index
- the class index to get the weight vector forpublic double getBias(int index)
SimpleWeightVectorModel
0
will be returned.index = 0
should be usedgetBias
in interface SimpleWeightVectorModel
index
- the class index to get the weight vector forpublic int numWeightsVecs()
SimpleWeightVectorModel
numWeightsVecs
in interface SimpleWeightVectorModel
SimpleWeightVectorModel.getRawWeight(int)
can be called.public SPA clone()
clone
in interface Classifier
clone
in interface UpdateableClassifier
clone
in class BaseUpdateableClassifier
public void setUp(CategoricalData[] categoricalAttributes, int numericAttributes, CategoricalData predicting)
UpdateableClassifier
UpdateableClassifier.update(jsat.classifiers.DataPoint, int)
method.setUp
in interface UpdateableClassifier
categoricalAttributes
- an array containing the categorical
attributes that will be in each data pointnumericAttributes
- the number of numeric attributes that will be in
each data pointpredicting
- the information for the target class that will be
predictedpublic void update(DataPoint dataPoint, int targetClass)
UpdateableClassifier
update
in interface UpdateableClassifier
dataPoint
- the data point to learntargetClass
- the target class of the data pointpublic CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic 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 obtainpublic static Distribution guessC(DataSet d)
C
in Support PassiveAggressive.d
- the data set to get the guess forCopyright © 2017. All rights reserved.