public class NaiveBayes extends AbstractClassifier implements OptionHandler, WeightedInstancesHandler, TechnicalInformationHandler
@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)
Constructor and Description |
---|
NaiveBayes() |
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
String |
displayModelInOldFormatTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test
instance.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDisplayModelInOldFormat()
Get whether to display model output in the old, original
format.
|
String[] |
getOptions()
Gets the current settings of the classifier.
|
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.
|
String |
globalInfo()
Returns a string describing this classifier
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(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(String[] options)
Parses a given list of options.
|
void |
setUseKernelEstimator(boolean v)
Sets if kernel estimator is to be used.
|
void |
setUseSupervisedDiscretization(boolean newblah)
Set whether supervised discretization is to be used.
|
String |
toString()
Returns a description of the classifier.
|
void |
updateClassifier(Instance instance)
Updates the classifier with the given instance.
|
String |
useKernelEstimatorTipText()
Returns the tip text for this property
|
String |
useSupervisedDiscretizationTipText()
Returns the tip text for this property
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
public 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 Exception
buildClassifier
in interface Classifier
instances
- set of instances serving as training dataException
- if the classifier has not been generated
successfullypublic void updateClassifier(Instance instance) throws Exception
instance
- the new training instance to include in the modelException
- if the instance could not be incorporated in
the model.public double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedException
- if there is a problem generating the predictionpublic Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class AbstractClassifier
public void setOptions(String[] options) throws 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 stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public String toString()
public String useKernelEstimatorTipText()
public boolean getUseKernelEstimator()
public void setUseKernelEstimator(boolean v)
v
- Value to assign to m_UseKernelEstimatory.public String useSupervisedDiscretizationTipText()
public boolean getUseSupervisedDiscretization()
public void setUseSupervisedDiscretization(boolean newblah)
newblah
- true if supervised discretization is to be used.public String displayModelInOldFormatTipText()
public void setDisplayModelInOldFormat(boolean d)
d
- true if model ouput is to be shown in the old formatpublic boolean getDisplayModelInOldFormat()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(String[] argv)
argv
- the optionsCopyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.