All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.NaiveBayes
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.DistributionClassifier
|
+----weka.classifiers.NaiveBayes
- public class NaiveBayes
- extends DistributionClassifier
- implements OptionHandler, WeightedInstancesHandler
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,
Create an empty class such as the following:
public class NaiveBayesUpdateable extends NaiveBayes
implements UpdateableClassifier {
}
This 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.
- Version:
- $Revision: 1.6 $
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz)
-
NaiveBayes()
-
-
buildClassifier(Instances)
- Generates the classifier.
-
distributionForInstance(Instance)
- Calculates the class membership probabilities for the given test
instance.
-
getOptions()
- Gets the current settings of the classifier.
-
getUseKernelEstimator()
- Gets if kernel estimator is being used.
-
listOptions()
- Returns an enumeration describing the available options
-
main(String[])
- Main method for testing this class.
-
setOptions(String[])
- Parses a given list of options.
-
setUseKernelEstimator(boolean)
- Sets if kernel estimator is to be used.
-
toString()
- Returns a description of the classifier.
-
updateClassifier(Instance)
- Updates the classifier with the given instance.
NaiveBayes
public NaiveBayes()
buildClassifier
public void buildClassifier(Instances instances) throws Exception
- Generates the classifier.
- Parameters:
- instances - set of instances serving as training data
- Throws: Exception
- if the classifier has not been generated
successfully
- Overrides:
- buildClassifier in class Classifier
updateClassifier
public void updateClassifier(Instance instance) throws Exception
- Updates the classifier with the given instance.
- Parameters:
- instance - the new training instance to include in the model
- Throws: Exception
- if the instance could not be incorporated in
the model.
distributionForInstance
public double[] distributionForInstance(Instance instance) throws Exception
- Calculates the class membership probabilities for the given test
instance.
- Parameters:
- instance - the instance to be classified
- Returns:
- predicted class probability distribution
- Throws: Exception
- if there is a problem generating the prediction
- Overrides:
- distributionForInstance in class DistributionClassifier
listOptions
public Enumeration listOptions()
- Returns an enumeration describing the available options
- Returns:
- an enumeration of all the available options
setOptions
public void setOptions(String options[]) throws Exception
- Parses a given list of options. Valid options are:
-K
Use kernel estimation for modelling numeric attributes rather than
a single normal distribution.
- Parameters:
- options - the list of options as an array of strings
- Throws: Exception
- if an option is not supported
getOptions
public String[] getOptions()
- Gets the current settings of the classifier.
- Returns:
- an array of strings suitable for passing to setOptions
toString
public String toString()
- Returns a description of the classifier.
- Returns:
- a description of the classifier as a string.
- Overrides:
- toString in class Object
getUseKernelEstimator
public boolean getUseKernelEstimator()
- Gets if kernel estimator is being used.
- Returns:
- Value of m_UseKernelEstimatory.
setUseKernelEstimator
public void setUseKernelEstimator(boolean v)
- Sets if kernel estimator is to be used.
- Parameters:
- v - Value to assign to m_UseKernelEstimatory.
main
public static void main(String argv[])
- Main method for testing this class.
- Parameters:
- argv - the options
All Packages Class Hierarchy This Package Previous Next Index WEKA's home