public class PlattSMO extends SupportVectorLearner implements BinaryScoreClassifier, WarmRegressor, Parameterized, WarmClassifier
BinaryScoreClassifier
interface. For
regression any algorithm can be used as a warms start. For best results, warm
starts should be from algorithms that will have a similar solution to
PlattSMO.
SupportVectorLearner.CacheMode
Modifier and Type | Field and Description |
---|---|
protected double |
b
Bias
|
protected double |
b_low
Bias
|
protected double |
b_up
Bias
|
protected double[] |
fcache |
protected double[] |
label
Stores the true value of the data point
|
protected Vec |
weights
Weight values to apply to each data point
|
accelCache, alphas, cacheEvictions, evalCount, vecs
Constructor and Description |
---|
PlattSMO()
Creates a new SVM object with a
LinearKernel that uses no cache
mode. |
PlattSMO(KernelTrick kf)
Creates a new SVM object that uses no cache mode.
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
PlattSMO |
clone() |
protected double |
decisionFunction(int v)
Returns the local decision function for classification training purposes
without the bias term
|
protected double |
decisionFunctionR(int v)
Returns the local decision function for regression training purposes
without the bias term
|
double |
getC()
Returns the soft margin complexity parameter of the SVM
|
double |
getEpsilon()
Returns the epsilon insensitive loss value
|
int |
getMaxIterations()
Returns the maximum number of iterations
|
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.
|
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 solution tolerance
|
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C in a SVM. |
boolean |
isModificationOne()
Returns true if modification one is in use
|
double |
regress(DataPoint data) |
void |
setC(double C)
Sets the complexity parameter of SVM.
|
void |
setEpsilon(double epsilon)
Sets the epsilon for the epsilon insensitive loss when performing
regression.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations to perform of the training loop.
|
void |
setModificationOne(boolean modificationOne)
Sets where or not modification one or two should be used when training.
|
void |
setTolerance(double tolerance)
Sets the tolerance for the solution.
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
protected boolean |
takeStep(int i1,
int i2) |
protected boolean |
takeStepR(int i1,
int i2) |
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.
|
accessingRow, getCacheMode, getCacheValue, getKernel, k, kEval, kEval, kEvalSum, setAlphas, setCacheMode, setCacheSize, setCacheValue, setKernel, sparsify
protected double b
protected double b_low
protected double b_up
protected double[] fcache
protected double[] label
protected Vec weights
public PlattSMO()
LinearKernel
that uses no cache
mode.public PlattSMO(KernelTrick kf)
kf
- the kernel trick to usepublic 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, 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, 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 warmSolution)
WarmClassifier
trainC
in interface WarmClassifier
dataSet
- the data set to train onwarmSolution
- the solution to use to warm start this modelpublic void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onprotected boolean takeStep(int i1, int i2)
protected boolean takeStepR(int i1, int i2)
protected double decisionFunction(int v)
v
- the index of the point to selectprotected double decisionFunctionR(int v)
v
- the index of the point to selectpublic PlattSMO clone()
clone
in interface BinaryScoreClassifier
clone
in interface Classifier
clone
in interface Regressor
clone
in class Object
public boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
supportsWeightedData
in interface Regressor
public void setC(double C)
C
- the soft margin parameterpublic double getC()
public void setMaxIterations(int maxIterations)
maxIterations
- the maximum number of main iteration loopspublic int getMaxIterations()
public void setModificationOne(boolean modificationOne)
modificationOne
- true
to us modificaiotn one, false
to use modification two.public boolean isModificationOne()
public void setTolerance(double tolerance)
tolerance
- the tolerance for the solutionpublic double getTolerance()
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, ExecutorService threadPool)
public void setEpsilon(double epsilon)
epsilon
- the positive value for the acceptable error when doing
regressionpublic double getEpsilon()
public 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)
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 modelpublic boolean warmFromSameDataOnly()
WarmRegressor
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 static Distribution guessC(DataSet d)
C
in a SVM.d
- the data set to get the guess forCopyright © 2017. All rights reserved.