To see the 1R method at work, consider the weather data of Table 1.2 (we will
encounter it many times again when looking at how learning algorithms work).
To classify on the final column,play, 1R considers four sets of rules, one for each
attribute. These rules are shown in Table 4.1. An asterisk indicates that a random
choice has been made between two equally likely outcomes. The number of
errors is given for each rule, along with the total number of errors for the rule
set as a whole. 1R chooses the attribute that produces rules with the smallest
number of errors—that is, the first and third rule sets. Arbitrarily breaking the
tie between these two rule sets gives:
outlook: sunny Æno
overcast Æyes
rainy Æyes
4.1 INFERRING RUDIMENTARY RULES 85
For each attribute,
For each value of that 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.
Figure 4.1Pseudocode for 1R.
Table 4.1 Evaluating the attributes in the weather data.
Attribute Rules Errors Total errors
1 outlook sunny Æno 2/5 4/14
overcast Æyes 0/4
rainy Æyes 2/5
2 temperature hot Æno 2/4 5/14
mild Æyes 2/6
cool Æyes 1/4
3 humidity high Æno 3/7 4/14
normal Æyes 1/7
4 windy false Æyes 2/8 5/14
true Æno 3/6
- A random choice was made between two equally likely outcomes.