public class DCDs extends Object implements BinaryScoreClassifier, Regressor, Parameterized, SingleWeightVectorModel, WarmClassifier, WarmRegressor
DCD
,
Serialized FormConstructor and Description |
---|
DCDs()
Creates a new DCDL2 SVM object
|
DCDs(int maxIterations,
boolean useL1)
Creates a new DCD SVM object
|
DCDs(int maxIterations,
double tolerance,
double C,
boolean useL1)
Creates a new DCD SVM object
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
DCDs |
clone() |
protected static double |
eq24(double beta_i,
double gN,
double gP,
double U)
returns the result of evaluation equation 24 of an individual index
|
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 penalty parameter for misclassifications.
|
double |
getEps()
Returns the epsilon insensitivity parameter used in regression problems.
|
int |
getMaxIterations()
Returns the maximum number of allowed training epochs
|
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.
|
double |
getTolerance()
Returns the tolerance value used to terminate early
|
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C in a SVM. |
boolean |
isUseBias()
Returns
true if an implicit bias term is in use, or false
if not. |
boolean |
isUseL1()
Returns true if the L1 form is in use
|
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
double |
regress(DataPoint data) |
void |
setC(double C)
Sets the penalty parameter for misclassifications.
|
void |
setEps(double eps)
Sets the
eps used in the epsilon insensitive loss function used
when performing regression. |
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations allowed through the whole training
set.
|
void |
setTolerance(double tolerance)
Sets the tolerance for the stopping condition when training, a small value near
zero allows training to stop early when little to no additional convergence
is possible.
|
void |
setUseBias(boolean useBias)
Sets whether or not an implicit bias term should be added to the inputs.
|
void |
setUseL1(boolean useL1)
Determines whether or not to use the L1 or L2 SVM
|
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 |
train(RegressionDataSet dataSet,
Regressor warmSolution)
Trains the regressor and constructs a model for regression using the
given data set.
|
void |
train(RegressionDataSet dataSet,
Regressor warmSolution,
ExecutorService threadPool)
Trains the regressor and constructs a model for regression using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
Classifier warmSolution)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
Classifier warmSolution,
ExecutorService threadPool)
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.
|
boolean |
warmFromSameDataOnly()
Some models can only be warm started from a solution trained on the
exact same data set as the model it is warm starting from.
|
public DCDs()
public DCDs(int maxIterations, boolean useL1)
maxIterations
- the maximum number of training iterationsuseL1
- whether or not to use L1 or L2 formpublic DCDs(int maxIterations, double tolerance, double C, boolean useL1)
maxIterations
- the maximum number of training iterationstolerance
- the tolerance value for early stoppingC
- the misclassification penaltyuseL1
- whether or not to use L1 or L2 formpublic void setC(double C)
C
- the penalty parameter in (0, Inf)public double getC()
public void setEps(double eps)
eps
used in the epsilon insensitive loss function used
when performing regression. Errors in the output that less than
eps
during training are treated as correct.
eps
- the non-negative value to use as the error tolerance in regressionpublic double getEps()
public void setTolerance(double tolerance)
tolerance
- the tolerance value to use to stop earlypublic double getTolerance()
public void setUseL1(boolean useL1)
useL1
- true to use the L1 form, false to use the L2 form.public boolean isUseL1()
public void setMaxIterations(int maxIterations)
maxIterations
- the maximum number of training epochspublic int getMaxIterations()
public void setUseBias(boolean useBias)
useBias
- true
to add an implicit bias term to inputs,
false
to use the input data as provided.public boolean isUseBias()
true
if an implicit bias term is in use, or false
if not.true
if an implicit bias term is in use, or false
if not.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 void trainC(ClassificationDataSet dataSet, Classifier warmSolution, ExecutorService threadPool)
WarmClassifier
trainC
in interface WarmClassifier
dataSet
- the data set to train onwarmSolution
- the solution to use to warm start this modelthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet, Classifier warmSolution)
WarmClassifier
trainC
in interface WarmClassifier
dataSet
- the data set to train onwarmSolution
- the solution to use to warm start this modelpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
supportsWeightedData
in interface Regressor
public boolean warmFromSameDataOnly()
WarmClassifier
true
will be returned. The behavior for training on a
different data set when this is defined is undefined. It may cause an
error, or it may cause the algorithm to take longer or reach a worse
solution. true
, it is important that the data set be unaltered - this
includes mutating the values stored or re-arranging the data points
within the data set.warmFromSameDataOnly
in interface WarmClassifier
warmFromSameDataOnly
in interface WarmRegressor
true
if the algorithm can only be warm started from the
model trained on the exact same data set.public DCDs clone()
clone
in interface BinaryScoreClassifier
clone
in interface Classifier
clone
in interface Regressor
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 void train(RegressionDataSet dataSet, Regressor warmSolution, ExecutorService threadPool)
WarmRegressor
train
in interface WarmRegressor
dataSet
- the data set to train onwarmSolution
- the solution to use to warm start this modelthreadPool
- the source of threads to use.public void train(RegressionDataSet dataSet, ExecutorService threadPool)
public void train(RegressionDataSet dataSet)
public void train(RegressionDataSet dataSet, Regressor warmSolution)
WarmRegressor
train
in interface WarmRegressor
dataSet
- the data set to train onwarmSolution
- the solution to use to warm start this modelprotected static double eq24(double beta_i, double gN, double gP, double U)
beta_i
- the weight coefficent valuegN
- the g'n(beta_i) valuegP
- the g'p(beta_i) valueU
- the upper bound value obtained from getU(double)
public static Distribution guessC(DataSet d)
C
in a SVM.d
- the data set to get the guess forCopyright © 2017. All rights reserved.