Log inStart free
LESSON 4.11 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Linear regression and least squares

Watch a line settle where its squared misses add up to the least.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.11 · REGRESSION BAY10 HOUSES · MEAN 84.5 M² · MEAN 170.6 K$
01
Stage 1 of 6 · Plot the data
Each dot is one house: its size in m² and its price in k$.
Explain it simply

Each teal dot is one house. Left to right is its size, and bottom to top is its price. Bigger houses tend to cost more, so the dots climb. The table on the right also lists each house's age and number of rooms.

A scatter plot of 10 houses. Size runs from 53 to 127 m², and price from 93 to 286 k$. A table lists size, age, rooms and price.

house: size, priceprediction ŷmiss e, its square, SSEslopes βmean, true slopes, size-only line
4060801001201400100200300size (m²)price (k$)157192112210826418431083641874124352865533215461277527176034293881403116962162132106522171#size m²age yrroomsprice k$housesprice vs size4060801001201400100200300size (m²)price (k$)157192112210826418431083641874124352865533215461277527176034293881403116962162132106522171#size m²age yrroomsprice k$housesprice vs size
Toy: 10 seeded houses · price ≈ 40 + 2·size − 2·age + noise, in k$ · 6 more samples for stage 6
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
yi=β0+β1 xi+εi\sy{y}{data}{y_i} = \sy{b0}{param}{\beta_0} + \sy{b1}{param}{\beta_1}\,\sy{x}{data}{x_i} + \sy{e}{grad}{\varepsilon_i}
n=10,xˉ=84.5 m2,yˉ=170.6 k$n = 10,\quad \bar x = 84.5\ \text{m}^2,\quad \bar y = 170.6\ \text{k\$}

The model says price is a straight line in size, plus noise.

Common mix-ups

MYTHA high R² means a straight line is the right model.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the price trend bends up, what shape do the misses make?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.