|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.AbstractClassifier
weka.classifiers.bayes.NaiveBayes
public class 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, Pat Langley: Estimating Continuous Distributions in Bayesian Classifiers. In: Eleventh Conference on Uncertainty in Artificial Intelligence, San Mateo, 338-345, 1995.
@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 Summary | |
---|---|
NaiveBayes()
|
Method Summary | |
---|---|
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 |
Methods inherited from class weka.classifiers.AbstractClassifier |
---|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NaiveBayes()
Method Detail |
---|
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 data
Exception
- if the classifier has not been generated
successfullypublic void updateClassifier(Instance instance) throws Exception
instance
- the new training instance to include in the model
Exception
- 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 classified
Exception
- 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 strings
Exception
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public String toString()
toString
in class Object
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 options
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |