Algorithms for �Classification:
The Basic Methods
Outline
2
Classification
3
Simplicity first
4
Bayesian (Statistical) modeling
5
Probabilities for weather data
6
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 | True | 3 | 3 | | |
Rainy | 3 | 2 | Cool | 3 | 1 | | | | | | | | |
Sunny | 2/9 | 3/5 | Hot | 2/9 | 2/5 | High | 3/9 | 4/5 | False | 6/9 | 2/5 | 9/14 | 5/14 |
Overcast | 4/9 | 0/5 | Mild | 4/9 | 2/5 | Normal | 6/9 | 1/5 | True | 3/9 | 3/5 | | |
Rainy | 3/9 | 2/5 | Cool | 3/9 | 1/5 | | | | | | | | |
Outlook | Temp | Humidity | Windy | Play |
Sunny | Hot | High | False | No |
Sunny | Hot | High | True | No |
Overcast | Hot | High | False | Yes |
Rainy | Mild | High | False | Yes |
Rainy | Cool | Normal | False | Yes |
Rainy | Cool | Normal | True | No |
Overcast | Cool | Normal | True | Yes |
Sunny | Mild | High | False | No |
Sunny | Cool | Normal | False | Yes |
Rainy | Mild | Normal | False | Yes |
Sunny | Mild | Normal | True | Yes |
Overcast | Mild | High | True | Yes |
Overcast | Hot | Normal | False | Yes |
Rainy | Mild | High | True | No |
Probabilities for weather data
7
Outlook | Temp. | Humidity | Windy | Play |
Sunny | Cool | High | True | ? |
Likelihood of the two classes For “yes” = 2/9 × 3/9 × 3/9 × 3/9 × 9/14 = 0.0053 For “no” = 3/5 × 1/5 × 4/5 × 3/5 × 5/14 = 0.0206 Conversion into a probability by normalization: P(“yes”) = 0.0053 / (0.0053 + 0.0206) = 0.205 P(“no”) = 0.0206 / (0.0053 + 0.0206) = 0.795 |
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 | True | 3 | 3 | | |
Rainy | 3 | 2 | Cool | 3 | 1 | | | | | | | | |
Sunny | 2/9 | 3/5 | Hot | 2/9 | 2/5 | High | 3/9 | 4/5 | False | 6/9 | 2/5 | 9/14 | 5/14 |
Overcast | 4/9 | 0/5 | Mild | 4/9 | 2/5 | Normal | 6/9 | 1/5 | True | 3/9 | 3/5 | | |
Rainy | 3/9 | 2/5 | Cool | 3/9 | 1/5 | | | | | | | | |
Bayes’s rule
8
Thomas Bayes
Born: 1702 in London, England�Died: 1761 in Tunbridge Wells, Kent, England
from Bayes “Essay towards solving a problem in the doctrine of chances” (1763)
Naïve Bayes for classification
9
Weather data example
10
Outlook | Temp. | Humidity | Windy | Play |
Sunny | Cool | High | True | ? |
Evidence E
Probability of
class “yes”
The “zero-frequency problem”
11
*Modified probability estimates
12
Sunny
Overcast
Rainy
Missing values
13
Outlook | Temp. | Humidity | Windy | Play |
? | Cool | High | True | ? |
Likelihood of “yes” = 3/9 × 3/9 × 3/9 × 9/14 = 0.0238 Likelihood of “no” = 1/5 × 4/5 × 3/5 × 5/14 = 0.0343 P(“yes”) = 0.0238 / (0.0238 + 0.0343) = 41% P(“no”) = 0.0343 / (0.0238 + 0.0343) = 59% |
Numeric attributes
14
Karl Gauss, 1777-1855
great German mathematician
Statistics for�weather data
15
Outlook | Temperature | Humidity | Windy | Play | |||||||||
| Yes | No | | Yes | No | | Yes | No | | Yes | No | Yes | No |
Sunny | 2 | 3 | | 64, 68, | 65, 71, | | 65, 70, | 70, 85, | False | 6 | 2 | 9 | 5 |
Overcast | 4 | 0 | | 69, 70, | 72, 80, | | 70, 75, | 90, 91, | True | 3 | 3 | | |
Rainy | 3 | 2 | | 72, … | 85, … | | 80, … | 95, … | | | | | |
Sunny | 2/9 | 3/5 | | μ =73 | μ =75 | | μ =79 | μ =86 | False | 6/9 | 2/5 | 9/14 | 5/14 |
Overcast | 4/9 | 0/5 | | σ =6.2 | σ =7.9 | | σ =10.2 | σ =9.7 | True | 3/9 | 3/5 | | |
Rainy | 3/9 | 2/5 | | | | | | | | | | | |
Classifying a new day
16
Outlook | Temp. | Humidity | Windy | Play |
Sunny | 66 | 90 | true | ? |
Likelihood of “yes” = 2/9 × 0.0340 × 0.0221 × 3/9 × 9/14 = 0.000036 Likelihood of “no” = 3/5 × 0.0291 × 0.0380 × 3/5 × 5/14 = 0.000136 P(“yes”) = 0.000036 / (0.000036 + 0. 000136) = 20.9% P(“no”) = 0.000136 / (0.000036 + 0. 000136) = 79.1% |
*Probability densities
17
Naïve Bayes: discussion
18
Naïve Bayes Extensions
19
Summary
20