Linear Regression

18 min read

Linear regression predicts a number from other numbers. For example, it can predict the rent of a flat from its area. In this lesson you draw a straight line through dots, measure how wrong the line is, and find the best line.

New words

Linear regression
A method that predicts a number using a straight line.
Slope (w)
How much the answer goes up when the input goes up by 1.
Intercept (b)
The answer the line gives when the input is 0.
Error
The real value minus the predicted value, for one example.
MSE
Mean squared error: the average of the squared errors.
Best fit line
The line with the smallest MSE on the data.

What you will learn

  1. How much rent should Priya expect?
  2. What is the equation of a line?
  3. How wrong is the line for one flat?
  4. What is mean squared error?
  5. What is the best line?
  6. What if there is more than one feature?
  7. Try it: find the best line
  8. When is a straight line a poor fit?
  9. Common mistakes
  10. Explain it to a friend
  11. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap