Chapter 2 of 5

Measuring the Errors

How do we know if a line is good or bad?

The gaps between each dot and the line — those are errors (residuals).

100200300400500600House Size (sqft)$0$50k$100k$150k$200k$250k$300kPrice ($) +6,881-64,487+18,482-14,836-1,095+27,814+21,058+46,036+150-3,702+41,116-20,367+42,090+59,339-3,017

Some positive, some negative. They cancel out. Not useful.

100200300400500600House Size (sqft)$0$50k$100k$150k$200k$250k$300kPrice ($) +6,881-64,487+18,482-14,836-1,095+27,814+21,058+46,036+150-3,702+41,116-20,367+42,090+59,339-3,017
Sum of errors = +155,462

Square each error. Now they're all positive — and big errors get punished more.

100200300400500600House Size (sqft)$0$50k$100k$150k$200k$250k$300kPrice ($)

Drag the line. Watch the total squared error change. Can you minimize it?

100200300400500600House Size (sqft)$0$50k$100k$150k$200k$250k$300kPrice ($)slopeintercept
Your SSE 0
Best possible: 11,622,569,746

Built with SvelteKit + D3.js