public class NaiveBayes extends AbstractClassifier implements OptionHandler, WeightedInstancesHandler, WeightedAttributesHandler, TechnicalInformationHandler, Aggregateable<NaiveBayes>
@inproceedings{John1995, address = {San Mateo}, author = {George H. John and Pat Langley}, booktitle = {Eleventh Conference on Uncertainty in Artificial Intelligence}, pages = {338-345}, publisher = {Morgan Kaufmann}, title = {Estimating Continuous Distributions in Bayesian Classifiers}, year = {1995} }Valid options are:
-K Use kernel density estimator rather than normal distribution for numeric attributes
-D Use supervised discretization to process numeric attributes
-O Display model in old format (good when there are many classes)
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
Constructor and Description |
---|
NaiveBayes() |
Modifier and Type | Method and Description |
---|---|
NaiveBayes |
aggregate(NaiveBayes toAggregate)
Aggregate an object with this one
|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
java.lang.String |
displayModelInOldFormatTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance.
|
void |
finalizeAggregation()
Call to complete the aggregation process.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
Estimator |
getClassEstimator()
Get the class estimator.
|
Estimator[][] |
getConditionalEstimators()
Get all the conditional estimators.
|
boolean |
getDisplayModelInOldFormat()
Get whether to display model output in the old, original format.
|
Instances |
getHeader()
Return the header that this classifier was trained with
|
java.lang.String[] |
getOptions()
Gets the current settings of the classifier.
|
java.lang.String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed
information about the technical background of this class, e.g., paper
reference or book this class is based on.
|
boolean |
getUseKernelEstimator()
Gets if kernel estimator is being used.
|
boolean |
getUseSupervisedDiscretization()
Get whether supervised discretization is to be used.
|
java.lang.String |
globalInfo()
Returns a string describing this classifier
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
void |
setDisplayModelInOldFormat(boolean d)
Set whether to display model output in the old, original format.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setUseKernelEstimator(boolean v)
Sets if kernel estimator is to be used.
|
void |
setUseSupervisedDiscretization(boolean s)
Set whether supervised discretization is to be used.
|
java.lang.String |
toString()
Returns a description of the classifier.
|
void |
updateClassifier(Instance instance)
Updates the classifier with the given instance.
|
java.lang.String |
useKernelEstimatorTipText()
Returns the tip text for this property
|
java.lang.String |
useSupervisedDiscretizationTipText()
Returns the tip text for this property
|
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class AbstractClassifier
Capabilities
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in interface Classifier
instances
- set of instances serving as training datajava.lang.Exception
- if the classifier has not been generated successfullypublic void updateClassifier(Instance instance) throws java.lang.Exception
instance
- the new training instance to include in the modeljava.lang.Exception
- if the instance could not be incorporated in the
model.public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedjava.lang.Exception
- if there is a problem generating the predictionpublic java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class AbstractClassifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-K Use kernel density estimator rather than normal distribution for numeric attributes
-D Use supervised discretization to process numeric attributes
-O Display model in old format (good when there are many classes)
setOptions
in interface OptionHandler
setOptions
in class AbstractClassifier
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String useKernelEstimatorTipText()
public boolean getUseKernelEstimator()
public void setUseKernelEstimator(boolean v)
v
- Value to assign to m_UseKernelEstimatory.public java.lang.String useSupervisedDiscretizationTipText()
public boolean getUseSupervisedDiscretization()
public void setUseSupervisedDiscretization(boolean s)
s
- true if supervised discretization is to be used.public java.lang.String displayModelInOldFormatTipText()
public void setDisplayModelInOldFormat(boolean d)
d
- true if model ouput is to be shown in the old formatpublic boolean getDisplayModelInOldFormat()
public Instances getHeader()
public Estimator[][] getConditionalEstimators()
public Estimator getClassEstimator()
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public NaiveBayes aggregate(NaiveBayes toAggregate) throws java.lang.Exception
Aggregateable
aggregate
in interface Aggregateable<NaiveBayes>
toAggregate
- the object to aggregatejava.lang.Exception
- if the supplied object can't be aggregated for some
reasonpublic void finalizeAggregation() throws java.lang.Exception
Aggregateable
finalizeAggregation
in interface Aggregateable<NaiveBayes>
java.lang.Exception
- if the aggregation can't be finalized for some reasonpublic static void main(java.lang.String[] argv)
argv
- the options