Evaluate a machine learning model
Use a trustworthy baseline, keep evaluation data independent, and understand a model’s errors.
Start with a baseline
A baseline is an intentionally simple method for the same task. If 90 out of 100 items belong to one class, always choosing that class scores 90% accuracy without distinguishing any minority examples. Choose metrics that reflect what you need to get right.
How it works
Begin with a simple baseline such as predicting the most common label. Compare the model on the same held-out examples with the same metric. Then inspect where each version fails. An improved average can still hide a group of examples where performance got worse.
Keep evaluation examples independent
Use training data for fitting parameters and validation data to compare choices. Keep the final test set apart until the approach is settled. Fit preprocessing on training data as part of the pipeline. Repeated copies of the same example across splits can make performance look better than it is.
Inspect the mistakes
Read some wrong predictions and group them by what went wrong. For a rare target you may want precision, which asks how many positive predictions were correct, and recall, which asks how many actual positives were found.
Check your understanding
A model flags eight items. Six are relevant, and there are ten relevant items altogether. Calculate precision and recall.
See the example and explanation
- Example 1
- Given
6 true positives, 2 false positives, 4 false negatives - Answer
Precision 75%, recall 60%
Precision is 6 divided by 8, which is 75%. Recall is 6 divided by 10, which is 60%.