三、算法说明

[math][/math] 朴素贝叶斯分类的正式定义如下: [br] [br] (1)设[math]x=[/math]{[math]a_1,a_2,...,a_m[/math]}为一个待分类项,而每个 [math]a[/math]为 [math]x[/math] 的一个特征属性。 [br] [br] (2)有类别集合 [math]C=[/math] {[math]y_1,y_2,...,y_n[/math]}。 [br][br] (3)计算[math]p\left(y_1\mid x\right),p\left(y_2\mid x\right),...,p\left(y_n\mid x\right)[/math]。 [br][br] (4)如果[math]p\left(y_k\mid x\right)=max[/math]{ [math]p\left(y_1\mid x\right),p\left(y_2\mid x\right),...,p\left(y_n\mid x\right)[/math]} ,则 [math]x\in y_k[/math]。[br][br] 现在的问题是如何计算第三步的条件概率,其步骤如下:[br][br] (1)找到一个已知分类的待分类项集合,这个集合称之为训练样本集。[br][br] (2)统计得到在各类别下各个特征属性的条件概率估计。[br][br] (3)如果各个特征属性是条件独立的,则根据贝叶斯定理有如下推导:[br][br] [math]p\left(y_i\mid x\right)=\frac{p\left(x\mid y_i\right)p\left(y_i\right)}{p\left(x\right)}[/math][br][br][br] 因为分母对于所有类别为常数,因此只要将分子最大化即可,又因为各特征属性是条件[br]独立的,所以有:[br][br] [math]p\left(x\mid y_i\right)p\left(y_i\right)=p\left(a_1\mid y_i\right)p\left(a_2\mid y_i\right)...p\left(a_m\mid y_i\right)=p\left(y_i\right)\prod p\left(a_j\mid y_i\right)[/math][br]

Information: 三、算法说明