diva.sketch.classification
Class BayesClassifier
java.lang.Object
diva.sketch.classification.AbstractClassifier
diva.sketch.classification.BayesClassifier
- All Implemented Interfaces:
- Classifier, TrainableClassifier
public class BayesClassifier
- extends AbstractClassifier
A naive bayes classifier. The training process calculates mu and
sigma for each feature (a random variable) of a class, and the
classification process uses the joint p.d.f. to compute the
probability of an example belonging to a particular class.
- Version:
- $Revision: 1.3 $
- Author:
- Heloise Hse (hwawen@eecs.berkeley.edu), Michael Shilman (michaels@eecs.berkeley.edu)
Field Summary |
protected static double |
MIN_SIGMA
The minimum sigma value; used to avoid divide-by-zero errors. |
Method Summary |
Classification |
classify(FeatureSet fs)
Given a feature vector (fs), compute the joint probability of
each class. |
void |
train(TrainingSet tset)
Compute mu's and sigma's for each class, also computes the
coefficients (one per class) that are used in the joint
p.d.f. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MIN_SIGMA
protected static final double MIN_SIGMA
- The minimum sigma value; used to avoid divide-by-zero errors.
- See Also:
- Constant Field Values
BayesClassifier
public BayesClassifier()
train
public void train(TrainingSet tset)
throws ClassifierException
- Compute mu's and sigma's for each class, also computes the
coefficients (one per class) that are used in the joint
p.d.f. calculation.
- Specified by:
train
in interface TrainableClassifier
- Overrides:
train
in class AbstractClassifier
- Throws:
ClassifierException
classify
public Classification classify(FeatureSet fs)
throws ClassifierException
- Given a feature vector (fs), compute the joint probability of
each class.
p(x)=(1/product(sigma_i)*(2*PI)^n/2)*exp(-0.5*sum((x_i-mu_i)/sigma_i)^2)
i = 1,2,...n
n = number of features
- Throws:
ClassifierException
Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.