Naive Bayes classifier
首先感谢 张洋 先生的这篇 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification),写的非常清楚明白。本文以此为基础做些总结。
Bayes Classifier 在 ISL 里零零散散提到一些,不正式写一下总觉得有点不痛快。
1. Bayes classifierPermalink
首先要说的是 Naive Bayes classifier 只是 Bayes classifier 的一种。Bayes classifier 的 定义 其实很简单:
在这个大框架下,Bayes classifier 衍生出了很多种,比如:
- Naive Bayes classifier
- Tree Augmented Naive Bayes classifier (TAN)
- Bayesian network Augmented Naive Bayes classifier (BAN)
- General Bayesian Network (GBN)
我们这里只讨论 Naive Bayes classifier。
2. Naive Bayes classifierPermalink
按 张洋 先生的文章,Bayes classifier 的定义可以这么写:
- 设
为一个 test point, 表示 的 feature 的值。 - class (label) 集合
- 我们把
简写成 - 如果
,则把 归到 对应的 class 下
根据 Bayes’ rule,有:
对
假设 feature 之间互相独立,我们可以有:
于是问题转化成求
于是 Naive Bayes classifier 可以定义为
3. Parameter Estimation and Event ModelsPermalink
… one must assume a distribution for the features from the training set. The assumptions on distributions of features are called the event model of the Naive Bayes classifier.
- for continuous features:
- Gaussian event model
- 统计所有 label 为
的 sample 的 feature 的值,得到 variance 和 mean ,进而得到一个高斯分布,把 的值带进去计算即可得到概率
- for discrete features
- multinomial event model
- Bernoulli event model
- 非常常用的两种 event model,具体自己看 wiki。如果需要深入研究,wiki 后面附了文章专门讨论这两种 event model 在 document classification 应用上的优劣。
4. 样本修正Permalink
另一个需要讨论的问题就是当
5. ExamplePermalink
原文和 wiki 都有,不好理解的时候看看例子就清楚了。
Comments