|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.DistributionClassifier
weka.classifiers.bayes.NaiveBayesSimple
Class for building and using a simple Naive Bayes classifier. Numeric attributes are modelled by a normal distribution. For more information, see
Richard Duda and Peter Hart (1973).Pattern Classification and Scene Analysis. Wiley, New York.
Field Summary | |
protected double[][][] |
m_Counts
All the counts for nominal attributes. |
protected double[][] |
m_Devs
The standard deviations for numeric attributes. |
protected Instances |
m_Instances
The instances used for training. |
protected double |
m_m
m parameter for Laplace m estimate, corresponding to size of pseudosample |
protected double[][] |
m_Means
The means for numeric attributes. |
protected double |
m_minStdDev
default minimum standard deviation |
protected double[] |
m_Priors
The prior probabilities of the classes. |
protected static double |
NORM_CONST
Constant for normal distribution. |
Constructor Summary | |
NaiveBayesSimple()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
double |
getM()
Get Laplace m parameter that controls amouont of smoothing |
double |
getMinStdDev()
Get the minimum allowable standard deviation. |
java.lang.String[] |
getOptions()
Gets the current settings. |
java.lang.String |
globalInfo()
Returns a string describing this clusterer |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options.. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
java.lang.String |
minStdDevTipText()
Returns the tip text for this property |
java.lang.String |
mTipText()
Returns the tip text for this property |
protected double |
normalDens(double x,
double mean,
double stdDev)
Density function of normal distribution returning log of probability |
static void |
normalizeLogs(double[] logProbs)
Converts an unormalized vector of logs of probabilities into a normalized distribution that sums to one |
protected void |
resetOptions()
Reset to default options |
void |
setM(double m)
Set Laplace m parameter that controls amouont of smoothing |
void |
setMinStdDev(double m)
Set the minimum value for standard deviation when calculating normal density. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
java.lang.String |
toString()
Returns a description of the classifier. |
double[] |
unNormalizedDistributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
Methods inherited from class weka.classifiers.DistributionClassifier |
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance |
Methods inherited from class weka.classifiers.Classifier |
forName, makeCopies |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected double[][][] m_Counts
protected double[][] m_Means
protected double[][] m_Devs
protected double[] m_Priors
protected Instances m_Instances
protected static double NORM_CONST
protected double m_minStdDev
protected double m_m
Constructor Detail |
public NaiveBayesSimple()
Method Detail |
protected void resetOptions()
public java.lang.String globalInfo()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String minStdDevTipText()
public void setMinStdDev(double m)
m
- minimum value for standard deviationpublic double getMinStdDev()
public java.lang.String mTipText()
public double getM()
public void setM(double m)
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
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 double[] unNormalizedDistributionForInstance(Instance instance) throws java.lang.Exception
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computedpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class DistributionClassifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computedpublic static void normalizeLogs(double[] logProbs)
public java.lang.String toString()
protected double normalDens(double x, double mean, double stdDev)
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 |