生成模型
假设训练集是((x_{i},y_{i})),i=1,2,3,...,N,对新输入的(x),要求对应的(y)是什么。
判别模型是指求条件概率分布(P(y|x))或者(y=f(x)),而生成模型需要先求联合分布(P(x,y))。对二分类来说,由贝叶斯公式,给一个(x),它属于(C_{1})的概率为:
[P(C_{1}|x)=frac{P(x|C_{1})P(C_{1})}{P(x|C_{1})P(C_{1})+P(x|C_{2})P(C_{2})}
]
(P(C_{1}),P(C_{2}))是先验概率,假设(P(x|C_{1}))和(P(x|C_{2}))服从某个概率分布,通过极大似然估计求得分布的参数,然后通过得到的概率分布计算(P(x|C_{1}))和(P(x|C_{2})),最终得到(P(C_{1}|x))的值。
如果假设(x)的每个属性值相互独立那么:
[P(C_{1}|x)=frac{P(x|C_{1})P(C_{1})}{P(x|C_{1})P(C_{1})+P(x|C_{2})P(C_{2})}=frac{P(C_{1})prod P(x^{(j)}|C_{1})}{prod P(x^{(j)}|C_{1})P(C_{1})+prod P(x^{(j)}|C_{2})P(C_{2})}
]
此时为朴素贝叶斯分类器。
另外:
[P(C_{1}|x)=frac{P(x|C_{1})P(C_{1})}{P(x|C_{1})P(C_{1})+P(x|C_{2})P(C_{2})}=frac{1}{1+frac{P(x|C_{2})P(C_{2})}{P(x|C_{1})P(C_{1})}}=frac{1}{1+e^{-z}}=sigma (z) (Sigmoid function)
]
其中:(z=ln frac{P(x|C_{2})P(C_{2})}{P(x|C_{1})P(C_{1})})
参考:
http://speech.ee.ntu.edu.tw/~tlkagk/courses/ML_2017/Lecture/Classification (v2).pdf