public class BBR extends Object implements Classifier, Parameterized, SingleWeightVectorModel
Modifier and Type | Class and Description |
---|---|
static class |
BBR.Prior
Valid priors that control what type of regularization is applied
|
Modifier | Constructor and Description |
---|---|
protected |
BBR(BBR toCopy)
Copy constructor
|
|
BBR(double regularization,
int maxIterations)
Creates a new BBR for L1 Logistic Regression object that will
use the given regularization value.
|
|
BBR(double regularization,
int maxIterations,
BBR.Prior prior)
Creates a new BBR Logistic Regression object that will use the given
regularization value.
|
|
BBR(int maxIterations)
Creates a new BBR for L1 Logistic Regression object that will
attempt to automatically determine the regularization value to use.
|
|
BBR(int maxIterations,
BBR.Prior prior)
Creates a new BBR Logistic Regression object that will attempt to
automatically determine the regularization value to use.
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
BBR |
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.
|
int |
getMaxIterations()
Returns the maximum number of iterations allowed
|
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.
|
BBR.Prior |
getPrior()
Returns the regularizing prior in use
|
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 |
getRegularization()
Returns the regularization penalty used if the auto value is not used
|
double |
getTolerance()
Returns the tolerance parameter that controls convergence
|
Vec |
getWeightVec()
Returns the weight vector used to compute results via a dot product.
|
boolean |
isAutoSetRegularization()
Returns whether or not the algorithm will attempt to select the
regularization term automatically
|
boolean |
isUseBias()
Returns
true if a bias term is in use, false otherwise. |
int |
numWeightsVecs()
Returns the number of weight vectors that can be returned.
|
void |
setAutoSetRegularization(boolean autoSetRegularization)
Sets whether or not the regularization term will be set automatically by
the algorithm, which is done as specified in the original paper.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations allowed before halting the
algorithm early.
|
void |
setPrior(BBR.Prior prior)
Sets the regularizing prior used
|
void |
setRegularization(double regularization)
Sets the regularization penalty to use if the algorithm has not been set
to choose one automatically.
|
void |
setTolerance(double tolerance)
Sets the convergence tolerance target.
|
void |
setUseBias(boolean useBias)
Sets whether or not an implicit bias term should be 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,
ExecutorService threadPool)
Trains the classifier and constructs a model for classification using the
given data set.
|
public BBR(double regularization, int maxIterations)
regularization
- the regularization penalty to applymaxIterations
- the maximum number of training iterations to performpublic BBR(double regularization, int maxIterations, BBR.Prior prior)
regularization
- the regularization penalty to applymaxIterations
- the maximum number of training iterations to performprior
- the prior to apply for regularizationpublic BBR(int maxIterations)
maxIterations
- the maximum number of training iterations to performpublic BBR(int maxIterations, BBR.Prior prior)
maxIterations
- the maximum number of training iterations to performprior
- the prior to apply for regularizationprotected BBR(BBR toCopy)
toCopy
- the object to copypublic void setRegularization(double regularization)
regularization
- sets the positive regularization penalty to usepublic double getRegularization()
public void setAutoSetRegularization(boolean autoSetRegularization)
setRegularization(double)
autoSetRegularization
- true
to choose the regularization
term automatically, false
to use whatever value was set before.public boolean isAutoSetRegularization()
true
if the regularization term is chosen automatically,
false
otherwise.public void setMaxIterations(int maxIterations)
maxIterations
- the maximum number of training iterationspublic int getMaxIterations()
public void setTolerance(double tolerance)
tolerance
- the positive convergence tolerance goalpublic double getTolerance()
public void setUseBias(boolean useBias)
useBias
- true
to add a bias term, false
to exclude
the bias term.public boolean isUseBias()
true
if a bias term is in use, false
otherwise.true
if a bias term is in use, false
otherwise.public void setPrior(BBR.Prior prior)
prior
- the prior to usepublic BBR.Prior getPrior()
public 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 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
trainC
in interface Classifier
dataSet
- the data set to train onpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
public BBR 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 obtainCopyright © 2017. All rights reserved.