Evaluating models: is it actually any good?

13 min read

A model's quality is only meaningful when measured on data it didn't learn from.

Splitting the data

  • Training set (often 70–80%): the model learns from this.
  • Validation set (10–15%): used to compare models and tune settings (called hyperparameters, like tree depth or learning rate).
  • Test set (10–15%): touched once, at the end, to estimate real-world performance.

Cross-validation rotates which slice is held out, giving a more reliable estimate on small datasets.

Data leakage is the most common way to fool yourself: information from the test set, or from the future, sneaks into training. Examples: normalizing data using statistics from the whole dataset; including a "loan was written off" field when predicting default; random splits on time-series data so the model trains on next month and is tested on last month. Leakage produces wonderful test scores and terrible real-world results.

Classification metrics

A confusion matrix counts four outcomes for a yes/no classifier:

Predicted yesPredicted no
Actually yesTrue positive (TP)False negative (FN)
Actually noFalse positive (FP)True negative (TN)
  • Accuracy = (TP + TN) / all. Misleading when classes are imbalanced: if 1% of transactions are fraud, "never fraud" is 99% accurate and useless.
  • Precision = TP / (TP + FP). Of the cases we flagged, how many were right? Matters when false alarms are costly.
  • Recall = TP / (TP + FN). Of the real cases, how many did we catch? Matters when misses are costly (cancer screening).
  • F1 score: a balance of precision and recall.
  • ROC-AUC: how well the model ranks positives above negatives across all thresholds.

Most classifiers output a probability; you choose the threshold that turns it into yes/no. Raising it trades recall for precision. That choice is a business and ethical decision, not only a technical one.

Regression metrics

Mean absolute error (average size of mistakes, in real units) and root mean squared error (punishes big misses more).

Beyond one number

Check performance across subgroups (age, region, device), on edge cases, and over time. A model that is 95% accurate overall can be much worse for a particular group, which is how many AI fairness failures happen.

Check your understanding

Check 1 of 2Module 3 · Machine learning

A cancer screening model must miss as few real cases as possible. Which metric matters most?

Check 2 of 2Module 3 · Machine learning

A model predicting customer churn includes a feature 'account closed date'. What is the problem?

Answer the checks, then mark this lesson complete
Completion and scores are saved in this browser.