文档ID 文档中的词 属于 C = CHINA 类
训练集 1 Chinese, Beijing, Chinese yes
2 Chinese,Chinese, Shanghai yes
3 Chinese Macao yes
4 Tokyo, Chinese, Japan no
测试集 5 Chinese Chinese Chinese Tokyo Japan ?
3.2
P(C|Chinese,Chinese,Chinese,Tokyo,Japan)
= P (Chinese,Chinese,Chinese,Tokyo,Japan|C) * P(C) / P(Chinese,Chinese,Chinese,Tokyo,Japan)
P (Chinese,Chinese,Chinese,Tokyo,Japan|C) = (P(Chinese|C)^3) * P(Tokyo|C) * P(Japan|C)
P(Chinese,Chinese,Chinese,Tokyo,Japan) = (P(Chinese)^3) * P(Tokyo) * P(Japan) = ((6/11)^3) * (1/11) * (1/11)
* 统一都要加上拉普拉斯平滑系数
解释:5 + 1 -> 属于 C = CHINA 类的情况下,特征词为 Chinese 的一共有5个;拉普拉斯平滑系数为1*1 = 1
8 + 6 -> 属于 C = CHINA 类的情况下,总共有8个单词;所有文档下,总共有6种不同的单词 ,即 有6种特征词
P(C) = 3/4 :4个文档种,共有3个属于 C = CHINA 类
P(Chinese|C) = (5+1)/(8+6) = 6/14 = 3/7
P(Tokyo|C) = (0+1)|(8+6) = 1/14
P(Japan|C) = (0+1)|(8+6) = 1/14
3.3
P(非C|Chinese,Chinese,Chinese,Tokyo,Japan) = P (Chinese,Chinese,Chinese,Tokyo,Japan|非C) * P(非C) / P(Chinese,Chinese,Chinese,Tokyo,Japan)