public class NaiveBayes extends AbstractClassifier
Performs classic bayesian prediction while making naive assumption that
all inputs are independent.
Naive Bayes is a classifier algorithm known
for its simplicity and low computational cost. Given n different classes, the
trained Naive Bayes classifier predicts for every unlabelled instance I the
class C to which it belongs with high accuracy.
Parameters:
Modifier and Type | Field and Description |
---|---|
protected AutoExpandVector<AttributeClassObserver> |
attributeObservers |
protected DoubleVector |
observedClassDistribution |
classifierRandom, modelContext, randomSeed, randomSeedOption, trainingWeightSeenByModel
classOptionNamesToPreparedObjects, options
Constructor and Description |
---|
NaiveBayes() |
Modifier and Type | Method and Description |
---|---|
static double[] |
doNaiveBayesPrediction(weka.core.Instance inst,
DoubleVector observedClassDistribution,
AutoExpandVector<AttributeClassObserver> attributeObservers) |
static double[] |
doNaiveBayesPredictionLog(weka.core.Instance inst,
DoubleVector observedClassDistribution,
AutoExpandVector<AttributeClassObserver> observers,
AutoExpandVector<AttributeClassObserver> observers2) |
void |
getModelDescription(StringBuilder out,
int indent)
Returns a string representation of the model.
|
protected Measurement[] |
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. |
String |
getPurposeString()
Gets the purpose of this object
|
double[] |
getVotesForInstance(weka.core.Instance inst)
Predicts the class memberships for a given instance.
|
boolean |
isRandomizable()
Gets whether this classifier needs a random seed.
|
void |
manageMemory(int currentByteSize,
int maxByteSize) |
protected AttributeClassObserver |
newNominalClassObserver() |
protected AttributeClassObserver |
newNumericClassObserver() |
void |
resetLearningImpl()
Resets this classifier.
|
void |
trainOnInstanceImpl(weka.core.Instance inst)
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. |
contextIsCompatible, copy, correctlyClassifies, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModelContext, getModelMeasurements, getNominalValueString, getSubClassifiers, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance
discoverOptionsViaReflection, getCLICreationString, getOptions, getPreparedClassOption, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
copy, measureByteSize, measureByteSize, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCLICreationString, getOptions, prepareForUse, prepareForUse
measureByteSize
protected DoubleVector observedClassDistribution
protected AutoExpandVector<AttributeClassObserver> attributeObservers
public String getPurposeString()
OptionHandler
getPurposeString
in interface OptionHandler
getPurposeString
in class AbstractClassifier
public void resetLearningImpl()
AbstractClassifier
resetLearningImpl
in class AbstractClassifier
public void trainOnInstanceImpl(weka.core.Instance inst)
AbstractClassifier
trainOnInstanceImpl
in class AbstractClassifier
inst
- the instance to be used for trainingpublic double[] getVotesForInstance(weka.core.Instance inst)
Classifier
inst
- the instance to be classifiedprotected Measurement[] getModelMeasurementsImpl()
AbstractClassifier
getModelMeasurementsImpl
in class AbstractClassifier
public void getModelDescription(StringBuilder out, int indent)
AbstractClassifier
getModelDescription
in class AbstractClassifier
out
- the stringbuilder to add the descriptionindent
- the number of characters to indentpublic boolean isRandomizable()
Classifier
protected AttributeClassObserver newNominalClassObserver()
protected AttributeClassObserver newNumericClassObserver()
public static double[] doNaiveBayesPrediction(weka.core.Instance inst, DoubleVector observedClassDistribution, AutoExpandVector<AttributeClassObserver> attributeObservers)
public static double[] doNaiveBayesPredictionLog(weka.core.Instance inst, DoubleVector observedClassDistribution, AutoExpandVector<AttributeClassObserver> observers, AutoExpandVector<AttributeClassObserver> observers2)
public void manageMemory(int currentByteSize, int maxByteSize)
Copyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.