# 李航-统计学习方法-笔记-4：朴素贝叶斯

## 朴素贝叶斯

$P(Y=c_k), k = 1,2, ..., K$

$P(X=x \ | \ Y = c_k) = P( X = (x^{(1)}, x^{(2)}, ..., x^{(n)}) \ | \ Y = c_k), k = 1,2, ..., K$

$\begin{split}P(X= x \ | \ Y = c_k) &= P(x^{(1)}, x^{(2)}, ..., x^{(n)} \ | \ Y = c_k) \\ &= \prod_{j=1}^{n} P(X^{(j)} = x^{(j)} \ | \ Y = c_k) \end{split}$

## 朴素贝叶斯分类

$\begin{split} P(Y | X) &= \frac{P(Y)\ P(X|Y)}{P(X)} \\ &= \frac{P(Y)\ P(X|Y)}{\sum_YP(Y)\ P(X|Y)}\end{split}$

$\begin{split} P(Y=c_k \ | \ X=x) &= \frac{P(X = x \ | \ Y = c_k) \ P(Y = c_k)}{P(X = x)} \\ &= \frac{P(X = x \ | \ Y = c_k) \ P(Y = c_k)}{\sum_k P(X = x \ | \ Y = c_k) \ P(Y = c_k)} \\ &= \frac{P(Y = c_k) \ \prod_j P(X^{(j)}=x^{(j)} | Y = c_k)}{\sum_k P(Y = c_k) \ \prod_j P(X^{(j)}=x^{(j)} | Y = c_k)} \end{split}$

$y = f(x) = \arg \max_{c_k} P(Y = c_k | X = x)$

$y = \arg \max_{c_k} P(Y = c_k) \prod_j P(X^{(j)}=x^{(j)} | Y = c_k)$

## 极大似然估计

$P(Y=c_k ) = \frac{\sum_{i=1}^{N} I(y_i = c_k)}{N}$

$P(X^{(j)} = a_{jl} \ | \ Y = c_k) = \frac{\sum_{i=1}^{N} I(x_i^{(j)} = a_{jl}, y_i = c_k)}{\sum_{i=1}^{N}I(y_i = c_k)}$

$P_{\lambda}(Y = c_k) = \frac{\sum_{i=1}^{N} I(y_i = c_k) + \lambda}{N + k \lambda}$

$P(X^{(j)} = a_{jl} \ | \ Y = c_k) = \frac{\sum_{i=1}^{N} I(x_i^{(j)} = a_{jl}, y_i = c_k) + \lambda}{\sum_{i=1}^{N}I(y_i = c_k) + S_j \lambda}$

$$\lambda=0$$时称为极大似然估计，$$\lambda=1$$时称为拉普拉斯平滑。

posted @ 2019-06-05 15:14  PilgrimHui  阅读(926)  评论(0编辑  收藏  举报