# 朴素贝叶斯实践

### 1、Opencv中的朴素贝叶斯

CvNormalBayesClassifier::train(Trains the model)

The method trains the Normal Bayes classifier. It follows the conventions of generic train "method" with the following limitations: only CV_ROW_SAMPLE data layout is supported; the input variables are all ordered; the output variable is categorical (i.e. elements of _responses must be integer numbers, though the vector may have 32fC1 type), missing measurements are not supported.

In addition, there is update flag that identifies, whether the model should be trained from scratch (update=false) or should be updated using new training data (update=true).

CvNormalBayesClassifier::predict(Predicts the response for sample(s))

The method predict estimates the most probable classes for the input vectors. The input vectors (one or more) are stored as rows of the matrixsamples. In case of multiple input vectors, there should be output vector results. The predicted class for a single input vector is returned by the method.

1）opencv2.3.1 源码

2）http://blog.csdn.net/godenlove007/article/details/8913007