Algorithms for �Classification:
The Basic Methods
Outline
2
Classification
3
Simplicity first
4
Inferring rudimentary rules
(assumes nominal attributes)
5
Pseudo-code for 1R
6
For each attribute, For each value of the attribute, make a rule as follows: count how often each class appears find the most frequent class make the rule assign that class to this attribute-value Calculate the error rate of the rules Choose the rules with the smallest error rate |
Evaluating the weather attributes
* indicates a tie
7
�Attribute | �Rules | �Errors | Total errors |
Outlook | Sunny → No | 2/5 | 4/14 |
| Overcast → Yes | 0/4 | |
| Rainy → Yes | 2/5 | |
Temp | Hot → No* | 2/4 | 5/14 |
| Mild → Yes | 2/6 | |
| Cool → Yes | 1/4 | |
Humidity | High → No | 3/7 | 4/14 |
| Normal → Yes | 1/7 | |
Windy | False → Yes | 2/8 | 5/14 |
| True → No* | 3/6 | |
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 |
Dealing with�numeric attributes
8
64 65 68 69 70 71 72 72 75 75 80 81 83 85 Yes | No | Yes Yes Yes | No No | Yes Yes Yes | No | Yes Yes | No |
Outlook | Temperature | Humidity | Windy | Play |
Sunny | 85 | 85 | False | No |
Sunny | 80 | 90 | True | No |
Overcast | 83 | 86 | False | Yes |
Rainy | 75 | 80 | False | Yes |
… | … | … | … | … |
The problem of overfitting
9
Discretization example
10
64 65 68 69 70 71 72 72 75 75 80 81 83 85 Yes | No | Yes Yes Yes | No No Yes Yes Yes | No | Yes Yes | No |
64 65 68 69 70 71 72 72 75 75 80 81 83 85 Yes No Yes Yes Yes | No No Yes Yes Yes | No Yes Yes No |
With overfitting avoidance
11
Attribute | Rules | Errors | Total errors |
Outlook | Sunny → No | 2/5 | 4/14 |
| Overcast → Yes | 0/4 | |
| Rainy → Yes | 2/5 | |
Temperature | ≤ 70.5 → Yes | 1/5 | 5/14 |
| > 70.5 and ≤ 77.5 → Yes | 2/5 | |
| > 77.5 → No* | 2/4 | |
Humidity | ≤ 82.5 → Yes | 1/7 | 3/14 |
| > 82.5 and ≤ 95.5 → No | 2/6 | |
| > 95.5 → Yes | 0/1 | |
Windy | False → Yes | 2/8 | 5/14 |
| True → No* | 3/6 | |
Discussion of 1R
12
Very Simple Classification Rules Perform Well on Most Commonly Used Datasets
Robert C. Holte, Computer Science Department, University of Ottawa
Summary
13