public class NewGLMNET extends Object implements WarmClassifier, Parameterized, SingleWeightVectorModel
LogisticRegressionDCD
are faster if using α = 0. SingleWeightVectorModel
interface.
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_EPS
The default tolerance for training is 0.01.
|
static int |
DEFAULT_MAX_OUTER_ITER
The default number of outer iterations of the training algorithm is
100 .
|
Modifier | Constructor and Description |
---|---|
|
NewGLMNET()
Creates a new L1 regularized Logistic Regression solver with
C = 1.
|
|
NewGLMNET(double C)
Creates a new L1 regularized Logistic Regression solver
|
|
NewGLMNET(double C,
double alpha)
Creates a new Elastic Net regularized Logistic Regression solver
|
protected |
NewGLMNET(NewGLMNET toCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
NewGLMNET |
clone() |
double |
getAlpha() |
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() |
int |
getMaxIters() |
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 |
getTolerance() |
static Distribution |
guessAlpha(DataSet d)
Guess the distribution to use for the trade off term term
(double) α in Elastic Net regularization. |
static Distribution |
guessC(DataSet d)
Guess the distribution to use for the regularization term
C in Logistic Regression. |
boolean |
isUseBias() |
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
void |
setAlpha(double alpha)
Using α = 1 corresponds to pure L1 regularization, and
α = 0 corresponds to pure L2 regularization.
|
void |
setC(double C)
Sets the regularization term, where smaller values indicate a larger
regularization penalty.
|
void |
setMaxIters(int maxOuterIters)
Sets the maximum number of training iterations for the algorithm,
specifically the outer loop as mentioned in the original paper.
|
void |
setTolerance(double e_out)
Sets the tolerance parameter for convergence.
|
void |
setUseBias(boolean useBias)
Controls whether or not an un-regularized bias term is added to the
model.
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
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 static final double DEFAULT_EPS
public static final int DEFAULT_MAX_OUTER_ITER
public NewGLMNET()
public NewGLMNET(double C)
C
- the regularization termpublic NewGLMNET(double C, double alpha)
C
- the regularization termalpha
- the fraction of weight (in [0, 1]) to apply to L1
regularization instead of L2 regularization.protected NewGLMNET(NewGLMNET toCopy)
toCopy
- the object to copypublic void setC(double C)
C
- the positive regularization termpublic double getC()
public void setAlpha(double alpha)
alpha
- the value in [0, 1] for determining the regularization
penalty's interpolation between pure L2 and L1
regularization.public double getAlpha()
public void setMaxIters(int maxOuterIters)
maxOuterIters
- the maximum number of outer iterationspublic int getMaxIters()
public void setTolerance(double e_out)
e_out
- the tolerance parameter.public double getTolerance()
public void setUseBias(boolean useBias)
useBias
- true
if an un-regularized bias term should be used
or false
to not use any bias term.public boolean isUseBias()
true
if an un-regularized bias term will be used
or false
to not use any bias term.public CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic 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, 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 void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
public NewGLMNET clone()
clone
in interface Classifier
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 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 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
true
if the algorithm can only be warm started from the
model trained on the exact same data set.public static Distribution guessAlpha(DataSet d)
(double) α
in Elastic Net regularization.d
- the data set to get the guess forpublic static Distribution guessC(DataSet d)
C
in Logistic Regression.d
- the data set to get the guess forCopyright © 2017. All rights reserved.