public class NaiveBayes extends Classifier 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)
Modifier and Type | Field and Description |
---|---|
protected static double |
DEFAULT_NUM_PRECISION
The precision parameter used for numeric attributes
|
protected Estimator |
m_ClassDistribution
The class estimator.
|
protected Discretize |
m_Disc
The discretization filter.
|
protected boolean |
m_displayModelInOldFormat |
protected Estimator[][] |
m_Distributions
The attribute estimators.
|
protected Instances |
m_Instances
The dataset header for the purposes of printing out a semi-intelligible
model
|
protected int |
m_NumClasses
The number of classes (or 1 for numeric class)
|
protected boolean |
m_UseDiscretization
Whether to use discretization than normal distribution
for numeric attributes
|
protected boolean |
m_UseKernelEstimator
Whether to use kernel density estimator rather than normal distribution
for numeric attributes
|
m_Debug
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.
|
protected String |
toStringOriginal()
Returns a description of the classifier in the old format.
|
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
protected Estimator[][] m_Distributions
protected Estimator m_ClassDistribution
protected boolean m_UseKernelEstimator
protected boolean m_UseDiscretization
protected int m_NumClasses
protected Instances m_Instances
protected static final double DEFAULT_NUM_PRECISION
protected Discretize m_Disc
protected boolean m_displayModelInOldFormat
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Classifier
Capabilities
public void buildClassifier(Instances instances) throws Exception
buildClassifier
in class 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 class Classifier
instance
- the instance to be classifiedException
- if there is a problem generating the predictionpublic Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
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 Classifier
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 Classifier
public String toString()
protected String toStringOriginal()
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 Classifier
public static void main(String[] argv)
argv
- the optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.