public class MultinomialNaiveBayes extends BaseUpdateableClassifier implements Parameterized
epoch
for MNBfinalizing
the model. This prevents the model from
being updated further, but reduces classification time. By default, this will
be done after a call to
trainC(jsat.classifiers.ClassificationDataSet)
but not after
update(jsat.classifiers.DataPoint, int)
Modifier | Constructor and Description |
---|---|
|
MultinomialNaiveBayes()
Creates a new Multinomial model with laplace smoothing
|
|
MultinomialNaiveBayes(double smoothing)
Creates a new Multinomial model with the given amount of smoothing
|
protected |
MultinomialNaiveBayes(MultinomialNaiveBayes other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
MultinomialNaiveBayes |
clone() |
void |
finalizeModel()
Finalizes the current model.
|
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 |
getSmoothing() |
boolean |
isFinalizeAfterTraining()
Returns
true if the model will be finalized after batch training. |
void |
setFinalizeAfterTraining(boolean finalizeAfterTraining)
If set
true , the model will be finalized after a call to
trainC(jsat.classifiers.ClassificationDataSet) . |
void |
setSmoothing(double smoothing)
Sets the amount of smoothing applied to the model.
|
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 |
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.
|
void |
update(DataPoint dataPoint,
int targetClass)
Updates the classifier by giving it a new data point to learn from.
|
getEpochs, setEpochs, trainEpochs
public MultinomialNaiveBayes()
public MultinomialNaiveBayes(double smoothing)
smoothing
- the amount of smoothing to applyprotected MultinomialNaiveBayes(MultinomialNaiveBayes other)
other
- the one to copypublic void setSmoothing(double smoothing)
smoothing
- the positive smoothing constantpublic double getSmoothing()
public void setFinalizeAfterTraining(boolean finalizeAfterTraining)
true
, the model will be finalized after a call to
trainC(jsat.classifiers.ClassificationDataSet)
. This prevents
the model from being updated in an online fashion for an reduction in
classification time.finalizeAfterTraining
- true
to finalize after a call to
train, false
to keep the model updatable.public boolean isFinalizeAfterTraining()
true
if the model will be finalized after batch training.
false
if it will be left in an updatable state.true
if the model will be finalized after batch training.public MultinomialNaiveBayes clone()
clone
in interface Classifier
clone
in interface UpdateableClassifier
clone
in class BaseUpdateableClassifier
public void trainC(ClassificationDataSet dataSet, ExecutorService threadPool)
Classifier
trainC
in interface Classifier
trainC
in class BaseUpdateableClassifier
dataSet
- the data set to train onthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
trainC
in class BaseUpdateableClassifier
dataSet
- the data set to train onpublic void finalizeModel()
update(jsat.classifiers.DataPoint, int)
to
throw an exception. This finalization reduces the cost of calling
classify(jsat.classifiers.DataPoint)
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 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 obtainCopyright © 2017. All rights reserved.