Chapter 5
Model Evaluation
Generalization, overfitting and underfitting, the confusion matrix and its metrics, holdout and cross-validation, ROC curves, ensemble methods, and model selection issues.
From: Topic 5a - Introduction to Evaluation Method for Classification, Topic 5 part 2 - Model Evaluation Metrics, Topic 5 part 3 - Evaluating Classifiers' Accuracy, Topic 5 part 4 - Model Selection Issues
Key concepts (5a)
- Generalization: the model's ability to give sensible outputs for inputs it has never seen.
- Overfitting: cost on training data is very small but generalization is unreliable; the model learned too much from the training set.
- Underfitting: the model has not learned enough, giving low generalization and unreliable predictions.
- The ideal model neither underfits nor overfits (appropriate fitting).
- Assess accuracy on a test set, not the training set. The best model is chosen by comparing several models on the test set.
Confusion matrix (5.2)
| Actual \ Predicted | C1 (positive) | ¬C1 (negative) |
|---|---|---|
| C1 | True Positive (TP) | False Negative (FN) |
| ¬C1 | False Positive (FP) | True Negative (TN) |
TP and TN are what the classifier gets right; FP and FN are what it gets wrong. For m classes, entry CMᵢ,ⱼ is the number of tuples of class i labelled as class j.
| Metric | Formula | Meaning |
|---|---|---|
| Accuracy (recognition rate) | (TP + TN) / All | % of test tuples correctly classified |
| Error rate | 1 − accuracy = (FP + FN) / All | % misclassified |
| Sensitivity | TP / P | True positive recognition rate |
| Specificity | TN / N | True negative recognition rate |
| Precision | TP / (TP + FP) | Exactness: of tuples labelled positive, how many really are |
| Recall | TP / (TP + FN) | Completeness: of positive tuples, how many were labelled positive |
| F measure (F1) | 2 × precision × recall / (precision + recall) | Harmonic mean of precision and recall |
| Fβ | (1 + β²) × P × R / (β² × P + R) | Weighted: β times as much weight on recall as on precision |
- Class imbalance problem: one class is rare (fraud, medical data), so most tuples are negative. Accuracy can look high while the positive class is poorly recognised, so use sensitivity and specificity.
- Precision and recall have an inverse relationship; a perfect score for each is 1.0.
Cancer example (5.2, slide 11)
- TP = 90, FN = 210, FP = 140, TN = 9,560 (P = 300, N = 9,700).
- Sensitivity = recall = 90/300 = 30%; specificity = 9,560/9,700 = 98.56%; precision = 90/230 = 39.13%.
- Accuracy is above 90%, yet the model is poor at finding the positive (cancer) class and good at the negative class.
Estimating accuracy (5.3)
| Method | How | Notes |
|---|---|---|
| Holdout | Randomly split into independent training (e.g. 2/3) and test (1/3) sets | Simple, but needs a large dataset |
| Random subsampling | Repeat holdout k times; accuracy = average | A variation of holdout |
| k-fold cross-validation | Split into k equal, mutually exclusive folds; in iteration i, fold Dᵢ is the test set and the rest train | k = 10 is most popular; trains on multiple splits, so better indication of performance on unseen data |
| Leave-one-out (LOOCV) | k = number of tuples; one sample left out for testing each time | For small datasets |
| Stratified cross-validation | Folds keep about the same class distribution as the full data | Recommended for accuracy estimation |
ROC curves (5.3)
- Receiver Operating Characteristic curves are a visual tool for comparing two classification models; they come from signal detection theory for radar in World War II.
- Show the trade-off between true positive rate (vertical axis) and false positive rate (horizontal axis).
- Rank test tuples in decreasing likelihood of being positive.
- Area under the curve (AUC) measures accuracy: a perfect model has AUC 1.0; the closer to the diagonal (AUC 0.5), the less accurate.
Ensemble methods (5.3)
Combine a series of k learned models M1…Mk into an improved model M* to increase accuracy. An ensemble of trees gives a more flexible decision boundary than a single tree.
| Method | Idea |
|---|---|
| Bagging | Averaging the prediction over a collection of classifiers. Often much more accurate than one classifier, more robust to noise and overfitting, because it reduces variance |
| Boosting | Weighted vote. Training tuples get weights; after Mᵢ is learned, weights are updated so Mᵢ₊₁ pays more attention to the tuples Mᵢ misclassified. Each classifier's vote is weighted by its accuracy |
| Random forest | A “forest” of decision trees, each split on a random selection of attributes; the class with the most votes wins. Built with bagging plus random attribute selection; many uncorrelated trees outperform any single one |
Model selection issues (5.4)
| Issue | Meaning |
|---|---|
| Accuracy | Percentage correct / error rate in predicting the class |
| Speed | Time to build the model (training) and to use it (prediction); computational cost |
| Robustness | Correct predictions despite noise or missing values |
| Scalability | Building the classifier efficiently from large amounts of data |
| Interpretability | Understanding and insight the model gives; subjective, harder to assess (e.g. tree size, rule compactness) |
No single classification method is superior for all data sets. Accuracy, training time, robustness, scalability and interpretability involve trade-offs. Significance tests and ROC curves help model selection.