Outlook |
Temperature |
Humidity |
Windy |
Play |
|
Yes |
No |
|
Yes |
No |
|
Yes |
No |
|
Yes |
No |
Yes |
No |
Sunny |
2 |
3 |
Hot |
2 |
2 |
High |
3 |
4 |
False |
6 |
2 |
9 |
5 |
Overcast |
4 |
0 |
Mild |
4 |
2 |
Normal |
6 |
1 |
Trur |
3 |
3 |
|
|
Rainy |
3 |
2 |
Cool |
3 |
1 |
|
|
|
|
|
|
|
|
As shown in the above table, we will calculate whether to play when the conditions are sunny, cool, high, and true. Of course, the decision tree can also be used. This section uses Naive Bayes to solve the problem.
B1, B2.... bn
First, let's take a look at the Bayesian formula. The probability of occurrence of a under B, that is, the probability that Sunny, cool, high, true is equal to yes, and the probability that it is equal to no, are all calculated, compare the size, which is big, and which is the result.
P (Yes | all) = P (all | yes) P (yes)/P (all) = P (Sunny | yes) P (cool | yes) P (high | yes) P (true | yes) P (yes)/P (all)
= 2/9*3/9*3/9*3/9*9/14/P (all) = 0.005/P (all)
P (no | all) = P (all | no) P (NO)/P (all) = P (Sunny | no) P (cool | No) P (high | no) P (true | no) P (NO)/P (all)
= 3/5*1/5*4/5*3/5*5/14/P (all) = 0.021/P (all)
Therefore, the probability of no is high. Therefore, sunny, cool, high, and true should not play the game.
Note that the table has a data value of 0, which means that when Outlook is overcast, if you do not play the ball or the probability is 0, you must play the ball as long as it is overcast, this violates the basic assumption of Naive Bayes that output depends on all attributes.
Machine Learning [3] Naive Bayes Classification