坚持朴素贝叶斯分类

Stuck on Naive Bayes Classification

我正在研究一个理解朴素贝叶斯分类的例子,想知道我的思维过程是否正确。所以我有三个用户,如果他们拥有 Nike 或 Reebok 鞋,或两者都有,则为真或假。因此用户可以拥有不止一双鞋。我想计算锐步拥有耐克的概率。这是我的数据:

User  | Nike  | Reebok 
Jesse | true  | false
Jake  | false | true 
John  | true  | true   - only user with both

以下是我尝试执行此操作的方法:

1) P(both | Reebok) = 1/2 = 50%  
2) Prior Prob = P(both | total user = 1/3 = 33%  
3) P(Reebok | total user = 2/3 = 67%
4) Posterior Prob = (50% * 33%)/67% = 25%

所以结果是,如果用户拥有 Nike 的,他们拥有 Reebok 的后验概率为 25%。

根据Bayes' theorem

p(Reebok | Nike) = p(Reebok) p(Nike | Reebok) / p(Nike)

在你的例子中:

  • p(Reebok) = 2/3
  • p(Nike) = 2/3
  • p(Nike | Reebok) = 1/2

所以,结果p(Reebok | Nike) = 1/2符合预期。