Data Mining
Ian H. Witten
Data Mining with Weka
Ian H. Witten Computer Science Department Waikato University New Zealand http://www.cs.waikato.ac.nz/~ihw http://www.cs.waikato.ac.nz/ml/weka
The problem
Classification (“supervised”) Given A set of classified examples Produce A way of classifying new examples Instances: described by fixed set of features Classes: discrete or continuous Interested in: Results? (classifying new instances) Model? (how the decision is made) “instances” “attributes” “classification” “regression” Association rules Look for rules that relate features to other features Clustering (“unsupervised”) There are no classes
Simplicity first!
Simple algorithms often work very well! There are many kinds of simple structure, eg:
One attribute does all the work All attributes contribute equally and independently A decision tree involving tests on a few attributes Rules that assign instances to classes Distance in instance space from a few class “prototypes” Result depends on a linear combination of attributes
Success of method depends on the domain
Agenda
A very simple strategy
Overfitting, evaluation
Statistical modeling
Bayes rule
Constructing decision trees Constructing rules
+ Association rules
Linear models
Regression, perceptrons, neural nets, SVMs, model trees
Instance-based learning and clustering
Hierarchical, probabilistic clustering
Engineering the input and output
Attribute selection, data transformations, PCA Bagging, boosting, stacking, co-training
One attribute does all the work
Learn a 1-level decision tree
i.e., rules that all test one particular attribute
Basic version
One branch for each value Each branch assigns most frequent class Error rate: proportion of instances that don’t belong to the majority class of their corresponding branch Choose attribute with smallest error rate
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 this attribute’s rules Choose the attribute with the smallest error rate
Example
3/6 True → No* 5/14 2/8 False → Yes Wind 1/7 Normal → Yes 4/14 3/7 High → No Humidity 5/14 4/14 Total errors 1/4 Cool → Yes 2/6 Mild → Yes 2/4 Hot → No* Temp 2/5 Rainy → Yes 0/4 Overcast → Yes 2/5 Sunny → No Outlook Errors Rules Attribute * indicates a tie No True High Mild Rainy Yes False Normal Hot Overcast Yes True High Mild Overcast Yes True Normal Mild Sunny Yes False Normal Mild Rainy Yes False Normal Cool Sunny No False High Mild Sunny Yes True Normal Cool Overcast No True Normal Cool Rainy Yes False Normal Cool Rainy Yes False High Mild Rainy Yes False High Hot Overcast No True High Hot Sunny No False High Hot Sunny Play Wind Humidity Temp Outlook No True High Mild Rainy Yes False Normal Hot Overcast Yes True High Mild Overcast Yes True Normal Mild Sunny Yes False Normal Mild Rainy Yes False Normal Cool Sunny No False High Mild Sunny Yes True Normal Cool Overcast No True Normal Cool Rainy Yes False Normal Cool Rainy Yes False High Mild Rainy Yes False High Hot Overcast No True High Hot Sunny No False High Hot Sunny Play Wind Humidity Temp Outlook