public class PassiveAggressive extends Object implements UpdateableClassifier, BinaryScoreClassifier, UpdateableRegressor, Parameterized, SingleWeightVectorModel
Modifier and Type | Class and Description |
---|---|
static class |
PassiveAggressive.Mode
Controls which version of the Passive Aggressive update is used
|
Constructor and Description |
---|
PassiveAggressive()
Creates a new Passive Aggressive learner that does 10 epochs and uses
PassiveAggressive.Mode.PA1 |
PassiveAggressive(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.
|
PassiveAggressive |
clone() |
double |
getBias()
Returns the bias term used for the model, or 0 of the model does not
support or was not trained with a bias term.
|
double |
getBias(int index)
Returns the bias term used with the weight vector for the given class
index.
|
double |
getC()
Returns the aggressiveness parameter
|
int |
getEpochs()
Returns the number of epochs used for training
|
double |
getEps()
Returns the maximum acceptable difference in prediction and truth
|
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()
Returns the only weight vector used for the model
|
Vec |
getRawWeight(int index)
Returns the raw weight vector associated with the given class index.
|
double |
getScore(DataPoint dp)
Returns the numeric score for predicting a class of a given data point,
where the sign of the value indicates which class the data point is
predicted to belong to.
|
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C in PassiveAggressive. |
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
double |
regress(DataPoint data) |
void |
setC(double C)
Set the aggressiveness parameter.
|
void |
setEpochs(int epochs)
Sets the number of whole iterations through the training set that will be
performed for training
|
void |
setEps(double eps)
Sets the range for numerical prediction.
|
void |
setMode(PassiveAggressive.Mode mode)
Sets which version of the PA update is used.
|
void |
setUp(CategoricalData[] categoricalAttributes,
int numericAttributes)
Prepares the classifier to begin learning from its
UpdateableRegressor.update(jsat.classifiers.DataPoint, double) method. |
void |
setUp(CategoricalData[] categoricalAttributes,
int numericAttributes,
CategoricalData predicting)
Prepares the classifier to begin learning from its
UpdateableClassifier.update(jsat.classifiers.DataPoint, int) method. |
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
void |
train(RegressionDataSet dataSet) |
void |
train(RegressionDataSet dataSet,
ExecutorService threadPool) |
void |
trainC(ClassificationDataSet dataSet)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
ExecutorService threadPool)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
update(DataPoint dataPoint,
double targetValue)
Updates the classifier by giving it a new data point to learn from.
|
void |
update(DataPoint dataPoint,
int targetClass)
Updates the classifier by giving it a new data point to learn from.
|
public PassiveAggressive()
PassiveAggressive.Mode.PA1
public PassiveAggressive(int epochs, PassiveAggressive.Mode mode)
epochs
- the number of training epochs to use during batch trainingmode
- which version of the update to performpublic 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 void setEps(double eps)
eps
- the maximum acceptable difference in prediction and truthpublic double getEps()
public void setEpochs(int epochs)
epochs
- the number of whole iterations through the data setpublic int getEpochs()
public Vec getRawWeight()
SingleWeightVectorModel
getRawWeight
in interface SingleWeightVectorModel
public double getBias()
SingleWeightVectorModel
getBias
in interface SingleWeightVectorModel
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 CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic double getScore(DataPoint dp)
BinaryScoreClassifier
getScore
in interface BinaryScoreClassifier
dp
- the data point to predict the class label ofpublic void trainC(ClassificationDataSet dataSet, ExecutorService threadPool)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
supportsWeightedData
in interface Regressor
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 setUp(CategoricalData[] categoricalAttributes, int numericAttributes)
UpdateableRegressor
UpdateableRegressor.update(jsat.classifiers.DataPoint, double)
method.setUp
in interface UpdateableRegressor
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 pointpublic void update(DataPoint dataPoint, int targetClass)
UpdateableClassifier
update
in interface UpdateableClassifier
dataPoint
- the data point to learntargetClass
- the target class of the data pointpublic void update(DataPoint dataPoint, double targetValue)
UpdateableRegressor
update
in interface UpdateableRegressor
dataPoint
- the data point to learntargetValue
- the target value of the data pointpublic void train(RegressionDataSet dataSet, ExecutorService threadPool)
public void train(RegressionDataSet dataSet)
public PassiveAggressive clone()
clone
in interface BinaryScoreClassifier
clone
in interface Classifier
clone
in interface UpdateableClassifier
clone
in interface Regressor
clone
in interface UpdateableRegressor
clone
in class Object
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 PassiveAggressive.d
- the data set to get the guess forCopyright © 2017. All rights reserved.