Machine Learning, FoundationsLesson 14 of 92

Module 2 · Linear models and the machinery of fitting

Diagnosing a model from the shape of its loss curve

In this lesson

  • 8 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 5 of 10 in this chapter

This chapter’s goalFit and diagnose a linear or logistic model end to end: compute its loss by hand on a handful of rows, tune the learning rate from the shape of the loss curve, state what a coefficient does and does not mean in the units of the data, and explain what ridge and lasso penalties change about the fitted parameters.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:58Not available
Full audiobookNot availableNot available
The textbook overfitting curve00.501020EpochLoss—— Validation loss– – Training lossTraining loss falls for as long as you let it. Validation loss bottoms out at epoch ten and rises fromthere, which is the model memorising this particular noise. The epoch where validation turns is whereyou should have stopped, and early_stopping does exactly that.
Training loss falls for as long as you let it. Validation loss bottoms out at epoch ten and rises from there, which is the model memorising this particular noise. The epoch where validation turns is where you should have stopped, and early_stopping does exactly that.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The plot you should make every time

Two lines, x-axis is epochs or steps, y-axis is loss. Training loss and validation loss on the same axes. This one plot answers more questions than any other artefact in machine learning, and it takes four lines of code.

Python
import matplotlib.pyplot as plt
plt.plot(history["train_loss"], label="train")
plt.plot(history["val_loss"], label="validation")
plt.legend(); plt.xlabel("epoch"); plt.ylabel("loss")

For scikit-learn models that do not record a history, HistGradientBoostingClassifier exposes validation_score_ per iteration, and SGDClassifier can be driven with partial_fit in a loop to build one manually. For anything in PyTorch you write it yourself, and you should.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Diagnosing a model from the shape of its loss curve’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/reading-a-loss-curve (Accessed: 29 November 2026).