Evaluating the Accuracy of a Classifier or Predictor
1. Why Not Simply Use Training Accuracy?
The resubstitution (training-set) accuracy is optimistically biased: a model can memorise (overfit) the training data and still generalise poorly — the classic example is a 1-NN classifier, which has 0% training error but a large test error. Hence, evaluation must use data not seen during training.
Holdout method: split the data into two independent sets — a training set (typically 2/3) and a test set (1/3). Accuracy is measured on the test set.
Full dataset (n tuples)
+--------------------------+-----------------+
| TRAINING (2/3) | TEST (1/3) |
+--------------------------+-----------------+
build model measure accuracy
Problem — the estimate depends on the split. The same accuracy figure can vary with different partitions of the data, so confidence intervals or resampling methods are needed.
2. Random Sampling (Repeated Holdout)
Repeat the holdout times with random, stratified partitions (stratified = class proportions preserved in each set) and average:
Some tuples are never used for testing, while others are tested repeatedly; still, this is the simplest unbiased-in-expectation estimator.
3. Cross-Validation (-fold CV)
Algorithm
- Randomly partition the data into mutually exclusive subsets ("folds") , each of roughly equal size (stratified).
- For each fold : train on all folds except , test on to get .
- Overall accuracy = average of the accuracies; every tuple is used for testing exactly once and for training times.
Choice of
| Training size per fold | Notes | |
|---|---|---|
| 2 | 50% | Weak, high bias |
| 5 | 80% | Good compromise |
| 10 | 90% | Standard practice — lowest bias/variance trade-off, reasonable computation |
| (Leave-One-Out, LOO) | (almost all) | Nearly unbiased; model builds; high variance; computationally expensive; stratified always |
Advantages of CV over a single holdout: all data are used both for training and testing; every tuple is tested exactly once; the estimate is less random and its variance can be reported. Limitation: computation ×; folds are not independent, so the training sets overlap (breaks strict independence assumptions); for time-series data folds must respect chronological order (forward-chaining / rolling-origin CV).
Stratified -fold cross-validation preserves class distribution in each fold — important for imbalanced classes.
4. Bootstrap
The 0.632 bootstrap draws tuples with replacement from a dataset of tuples; on average only of the tuples appear in the bootstrap sample, so the rest ( or ) form the test set ("out-of-bag" data).
Each tuple has probability of appearing. Accuracy estimate over bootstrap samples, correcting for the optimistic training accuracy:
Bootstrap is useful for small datasets and also gives standard errors/confidence intervals for almost any statistic; smoothed variants use a weight per tuple.
5. Estimating a Predictor's Accuracy (Numeric)
For numeric predictors, cross-validation and bootstrap are applied with the error measures instead of the accuracy fraction:
The last form is the relative error, which removes the influence of the scale of the target values (used e.g. in the Weka/C4.5 evaluation).
6. Model Comparison — Statistical Significance
-fold CV gives accuracy estimates per model (not independent!). To compare models A and B on the same folds:
with degrees of freedom — reject "models are equal" if exceeds the critical value (this is the cross-validated paired t-test of Dietterich, who also proposes 5×2 CV -test, McNemar's test and a test on differences of proportions for more reliable comparisons).
7. Practical Issues in Evaluation
| Issue | Recommendation |
|---|---|
| Class imbalance | Stratified folds, choose measures like F1/AUC/recall, resample (SMOTE) inside the fold |
| Data leakage | All preprocessing (normalisation, feature selection, discretisation, oversampling) must be fitted inside each fold, not on the whole dataset |
| Hyper-parameter tuning | Use a separate validation set or nested CV so the test set stays untouched |
| Temporal data | Time-ordered (rolling-origin) splits, no random shuffling |
| Grouped data | Group-aware CV so the same patient/customer is not in both train and test |
| Reporting | State the number of folds, the split strategy, mean ± standard deviation, and the metric used |
8. Exam Points
- Explain holdout, random subsampling, cross-validation (-fold and LOO) with diagrams and advantages — 10 marks (very frequent).
- Explain the 0.632 bootstrap and why approximately 63.2% of tuples appear — 5-7 marks.
- How do you estimate the accuracy of a predictor for numeric prediction (relative error, CV)? — 5 marks.
- Discuss the paired -test for comparing two classifiers — 5 marks.
- Why is the training-set accuracy not a valid estimate? — 3 marks.