Skip to content
Judith Solomon
Linear RegressionFundamentalsPython

Pizza — Linear Regression from Scratch

The first one. Diameter in, price out.

Role
Learning project
When
August 2026
Tools
Python, NumPy, scikit-learn, Matplotlib, Jupyter Notebook

Description

Predicting the price of a pizza from its diameter — the smallest possible regression problem, and the one where I learned what fitting a line actually means.

Cost functions, residuals, gradient descent, and how to tell a good fit from a lucky one. Keeping it here because pretending you started somewhere more impressive helps nobody.

What came out of it

Price against diameter, with the fitted line. The entire model, on a handful of points — which is the reason to start here.
The same data with a quadratic fit laid over the straight one. Past about eighteen inches the curve predicts a *falling* price for a bigger pizza — a neat picture of a model fitting the points it was given rather than the thing it is meant to describe.