|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.bayes.NaiveBayes
Class for a Naive Bayes classifier using estimator classes. Numeric estimator precision values are chosen based on analysis of the training data. For this reason, the classifier is not an UpdateableClassifier (which in typical usage are initialized with zero training instances) -- if you need the UpdateableClassifier functionality, use the NaiveBayesUpdateable classifier. The NaiveBayesUpdateable classifier will use a default precision of 0.1 for numeric attributes when buildClassifier is called with zero training instances.
For more information on Naive Bayes classifiers, see
George H. John and Pat Langley (1995). Estimating Continuous Distributions in Bayesian Classifiers. Proceedings of the Eleventh Conference on Uncertainty in Artificial Intelligence. pp. 338-345. Morgan Kaufmann, San Mateo.
Valid options are:
-K
Use kernel estimation for modelling numeric attributes rather than
a single normal distribution.
-D
Use supervised discretization to process numeric attributes.
Field Summary | |
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 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 |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
NaiveBayes()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
java.lang.String[] |
getOptions()
Gets the current settings of the classifier. |
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 |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
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 newblah)
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 |
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
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
Constructor Detail |
public NaiveBayes()
Method Detail |
public java.lang.String globalInfo()
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training data
java.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 model
java.lang.Exception
- if the instance could not be incorporated in
the model.public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if there is a problem generating the predictionpublic java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-K
Use kernel estimation for modelling numeric attributes rather than
a single normal distribution.
-D
Use supervised discretization to process numeric attributes.
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public java.lang.String toString()
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 newblah)
newblah
- true if supervised discretization is to be used.public static void main(java.lang.String[] argv)
argv
- the options
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |