public class SCW extends BaseUpdateableClassifier implements BinaryScoreClassifier, Parameterized, SingleWeightVectorModel
PassiveAggressive
. The SCW mode handles noisy and
nonlinearly separable datasets better. Modifier and Type | Class and Description |
---|---|
static class |
SCW.Mode
Which version of the algorithms shuld be used
|
Modifier | Constructor and Description |
---|---|
|
SCW()
Creates a new SCW learner
|
|
SCW(double eta,
SCW.Mode mode,
boolean diagonalOnly)
Creates a new SCW learner
|
protected |
SCW(SCW other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
SCW |
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
|
double |
getEta()
Returns the target correction confidence
|
SCW.Mode |
getMode()
Returns which algorithm 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.
|
Vec |
getWeightVec()
Returns the weight vector used to compute results via a dot product.
|
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C . |
static Distribution |
guessEta(DataSet d)
Guess the distribution to use for the regularization term
η . |
boolean |
isDiagonalOnly()
Returns
true if the covariance matrix is restricted to its diagonal entries |
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
void |
setC(double C)
Set the aggressiveness parameter.
|
void |
setDiagonalOnly(boolean diagonalOnly)
Using the full covariance matrix requires O(d2) work on
updates, where d is the dimension of the data.
|
void |
setEta(double eta)
SCW uses a probabilistic version of the margin and attempts to make a
correction so that the confidence with correct label would be of a
certain threshold, which is set by eta.
|
void |
setMode(SCW.Mode mode)
Controls which version of the algorithm 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. |
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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
trainC, trainC
public SCW()
public SCW(double eta, SCW.Mode mode, boolean diagonalOnly)
eta
- the margin confidence parameter in [0.5, 1]mode
- mode controlling which algorithm to usediagonalOnly
- whether or not to use only the diagonal of the
covariance matrixsetEta(double)
,
setMode(jsat.classifiers.linear.SCW.Mode)
,
setDiagonalOnly(boolean)
protected SCW(SCW other)
other
- object to copypublic void setEta(double eta)
eta
- the confidence to correct topublic double getEta()
public void setC(double C)
SCW.Mode.SCWI
and
SCW.Mode.SCWII
C
- the positive aggressiveness parameterpublic double getC()
public void setMode(SCW.Mode mode)
mode
- which algorithm to usepublic SCW.Mode getMode()
public void setDiagonalOnly(boolean diagonalOnly)
diagonalOnly
- true
to use only the diagonal of the covariancepublic boolean isDiagonalOnly()
true
if the covariance matrix is restricted to its diagonal entriestrue
if the covariance matrix is restricted to its diagonal entriespublic Vec getWeightVec()
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 SCW clone()
clone
in interface BinaryScoreClassifier
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 double getScore(DataPoint dp)
BinaryScoreClassifier
getScore
in interface BinaryScoreClassifier
dp
- the data point to predict the class label ofpublic 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
.d
- the data set to get the guess forpublic static Distribution guessEta(DataSet d)
η
.d
- the data set to get the guess forCopyright © 2017. All rights reserved.