Reading a Learning Curve to Decide What to Do Next
Use training and validation curves to decide whether to gather more data, change the model, fix the optimizer or look for a bug.
Key takeaways
- Curves against dataset size answer "will more data help?", while curves against iterations answer "is training going well?"
- A large gap that is still closing suggests more data will pay off.
- Two flat, nearby curves above your target mean volume alone is unlikely to get you there.
- Odd shapes, such as validation beating training or sudden spikes, have specific causes worth checking.
- Average several runs or folds before reading small differences.
A learning curve plots model error as something increases: the number of training examples, or the number of training iterations. Read two lines together, training error and validation error. Their level, the gap between them and the direction they are heading tell you what is likely to help next.
If both are high and close, work on the model or features. If training error is low and validation error much higher, add data or constrain the model. If validation error is still falling at the right edge, keep going.
Two kinds of curve
| Curve | Horizontal axis | Each point is | Main question |
|---|---|---|---|
| By training size | Number of examples | A model trained from scratch | Would more data help? |
| By training progress | Epochs or boosting rounds | A snapshot of one run | When to stop; is optimization healthy? |
An epoch is one pass through the training data. People call both plots learning curves, so check the axis before drawing a conclusion. A third relative, the validation curve, puts a hyperparameter such as tree depth on the horizontal axis.
Use the same metric for both lines, and measure training error without training-only effects such as dropout or augmentation.
Draw one yourself
This script trains two models on growing portions of a synthetic classification dataset and prints log loss, where lower is better.
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import StratifiedKFold, learning_curve
X, y = make_classification(n_samples=4000, n_features=20, n_informative=8,
flip_y=0.05, random_state=0)
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=0)
for model in (LogisticRegression(max_iter=1000),
RandomForestClassifier(random_state=0)):
sizes, train, val = learning_curve(
model, X, y, cv=cv, scoring="neg_log_loss",
train_sizes=[0.05, 0.1, 0.25, 0.5, 1.0],
shuffle=True, random_state=0)
print(type(model).__name__)
for n, tr, va in zip(sizes, -train.mean(axis=1), -val.mean(axis=1)):
print(n, round(tr, 3), round(va, 3)) One run gave roughly these values.
| Examples | Linear train | Linear validation | Forest train | Forest validation |
|---|---|---|---|---|
| 160 | 0.26 | 0.39 | 0.12 | 0.40 |
| 800 | 0.30 | 0.33 | 0.09 | 0.32 |
| 3,200 | 0.31 | 0.32 | 0.08 | 0.28 |
Interpreting the two models
For logistic regression, training loss rises as data grows, which is normal: it is harder to fit many points than a few. Validation loss falls and the two meet near 0.31 to 0.32. They have nearly converged, so thousands more rows of the same kind would likely change little. To do better, this model needs better features or more flexibility.
The random forest has a large gap, yet its validation loss is still falling at the right edge and is already below the linear model's. More data would plausibly help it further. A training loss far below validation loss is typical of deep forests and does not by itself mean something is broken. What matters is the validation trend.
Why the two lines move as they do
With very few examples, a flexible model can fit them almost perfectly, so training error starts low. What it learned from so little rarely transfers, so validation error starts high. As examples accumulate, the training set becomes harder to memorize and training error tends to rise. At the same time, the fitted pattern reflects the population better and validation error tends to fall.
The two approach each other. Where they would meet depends on the model family and the features. A straight line fitted to a curved relationship settles at a high value quickly, because more points only pin down the same wrong line more precisely. A flexible model has a lower possible meeting point but needs more data to get near it.
This explains a common surprise: with little data the simpler model can win, and with more data the ranking flips. In the table above, the linear model is slightly ahead at 160 examples and behind at 3,200. A comparison made on a small prototype sample may therefore not hold at full scale, so rerun it when the dataset grows.
Regularization shifts the picture. A stronger penalty raises training error and narrows the gap. It helps when the gap was the problem and hurts when both lines were already high.
Decide against a target
"High" and "low" need a reference. Draw a horizontal line for the performance you require, and if you can estimate it, another for the best plausible result, such as expert agreement.
- Training error above the target: more data will not rescue this setup, because validation error is rarely better than training error in a lasting way.
- Training below the target, validation above and falling: collect more data.
- Training below the target, validation above and flat: try regularization, different features or a different model, and check whether validation data differs from training data.
- Validation below the target: stop improving and move to final testing.
Extrapolating a size curve can estimate how much data you would need, with the cautions described in estimating data requirements.
What each action is likely to move
| Action | Effect on training error | Effect on the gap |
|---|---|---|
| Add more representative data | Often rises a little | Narrows |
| Add informative features | Falls | May change either way |
| Increase capacity | Falls | Usually widens |
| Strengthen regularization | Rises | Usually narrows |
| Train longer | Falls | May widen late in training |
| Clean wrong labels | Often falls | Depends on where the errors were |
These are tendencies, not guarantees. Use the table to state a prediction before an experiment. If you strengthen a penalty and the gap does not narrow at all, the gap probably has another source, such as a difference between the training and validation data.
Cost belongs in the choice too. Changing a penalty takes minutes. Labeling another 50,000 examples may take months. When the curves leave room for both, try the cheap experiment first, and use what it teaches to decide whether the expensive one is justified. A size curve is itself cheap to produce, since the smaller subsets train quickly, so there is little reason to commission new data without one.
Curves over training time
For a neural network or boosted model, plot both losses against epochs or rounds.
| Shape | Likely cause | Try |
|---|---|---|
| Both falling slowly | Learning rate low, or training unfinished | Raise the rate or train longer |
| Loss jumps or becomes NaN | Rate too high, unstable math, bad inputs | Lower the rate, inspect data, clip gradients |
| Training falls, validation turns up | Overfitting sets in | Stop earlier, regularize, add data |
| Both flat from the start | Not learning | Debug the pipeline |
| Regular sawtooth | Data order or schedule effects | Shuffle; check the schedule |
Stopping at the lowest validation loss is early stopping. Allow some patience, since the curve is noisy and can dip again. Because you used validation data to choose the stopping point, report performance on a separate test set.
For a flat curve, see debugging a model that will not learn. For the first plot of a neural run, a learning rate range test can save time.
Odd shapes and their causes
Validation better than training. Possible reasons include dropout or augmentation active when training loss is measured, a training loss averaged over an epoch while the model was still improving, an easier validation set or duplicated rows shared between splits.
Large permanent gap with plenty of data. The validation data may come from a different source or period. Hold out a slice drawn from the training distribution and compare the three.
Validation loss rising while accuracy holds steady. The model may be growing overconfident on the cases it gets wrong. Accuracy ignores confidence, while log loss punishes it. If you need probabilities, examine calibration.
Error rising with more data. Newly added rows may be noisier, mislabeled or from a new population. Read some.
Reduce the noise before reading
A single split at a small size can swing widely. Use several folds or random subsets and plot the mean with a band showing the spread. Keep the validation set fixed across training sizes where you can, so changes reflect training data and not a changing yardstick. Put the example count on a log axis.
Respect time and groups. For time-ordered data, grow the training window while validating on a later period. For grouped data, add whole groups. A naive random subsample in either case produces an optimistic curve.
From curve to next experiment
Finish by writing one sentence: "The curves suggest ___, so we will try ___ and expect ___." Then run it and redraw. If your prediction fails, your diagnosis was incomplete, which is useful to know.
Curves show how much error remains and roughly of what kind, but not which examples cause it. Pair them with error analysis, where you read the failures themselves, and with the theory in the bias-variance tradeoff.