Learning Curve
When a model performs poorly, the big question is: is it struggling because it hasn’t seen enough data, or because it’s the wrong kind of model (or settings) for the job? A learning curve is a simple diagnostic plot that helps you answer that without guessing.
What a learning curve showsA learning curve plots model performance versus the amount of training data used. You typically draw two curves:
- Training score: how well the model fits the data it learned from.
- Validation score (or cross-validation score): how well it generalizes to unseen data.
The x-axis is training set size; the y-axis is a metric like accuracy, F1, RMSE, or log loss. As you add more labeled examples, the curves reveal whether the model is improving and whether it’s overfitting.
How to read it (bias vs. variance)Learning curves make the bias-variance story visible:
- Overfitting (high variance): training score is high, validation score is much lower, and the gap persists. More data often helps close the gap.
- Underfitting (high bias): both training and validation scores are low and close together. More data doesn’t help much; you need a more expressive model, better features, or less regularization.
- Data-limited regime: validation score keeps rising with more data and hasn’t plateaued yet—collecting labels is likely worth it.
In spam detection, a learning curve can show that a linear model (e.g., scikit-learn’s LogisticRegression) is underfitting—both curves flatten early—suggesting richer text features or a different model. In fraud detection, a persistent train–validation gap can signal overfitting to rare patterns, pushing you toward stronger regularization or more labeled fraud cases. In scikit-learn, you’ll commonly generate these with:
from sklearn.model_selection import learning_curve
A learning curve plots a model’s performance (or loss) against training set size, typically showing separate training and validation curves. It reveals whether adding data is likely to improve generalization and helps diagnose underfitting (both curves poor and close) versus overfitting (training strong, validation weak). Learning curves guide decisions about collecting more labeled data versus changing model capacity, features, or regularization.
Think about learning to play guitar: at first, every extra hour of practice makes you noticeably better. Later, you still improve, but each extra hour helps less. A learning curve in machine learning is the same idea, shown as a simple plot.
It shows how a model’s performance changes as you give it more training examples (more “practice”). If the curve keeps improving, more data may help. If it flattens early, the model might be too simple or the problem is noisy. If it does great on training data but not on new data, that’s a warning sign of overfitting—like memorizing songs without really learning music.