Classical ML - Beginner - 12 min

Learn Linear Regression

A free visual AI and machine learning lesson with an interactive 3D visualization, plain-English theory, and quiz.

Last updated: 2026-05-13.

Simple theory: Linear regression predicts a continuous number by fitting a straight line through data. The best line is the one whose predictions are closest to the real values on average.

Imagine you're trying to predict the price of a house based on its size. Bigger house → higher price. Simple, right? That relationship — finding a straight line through data points — is exactly what Linear Regression does.

How does it work?

The algorithm tries different lines and measures how wrong each one is. The total wrongness is called the Loss (or Error). It keeps adjusting the line until the loss is as small as possible.

The line is described by two numbers: Slope (how steep it is) and Intercept (where it crosses the y-axis). These are the model's parameters that it learns from data.

Practice questions

  1. What does Linear Regression predict?
  2. What is the 'Loss' in Linear Regression?
  3. In the animation, what does the ball rolling downhill represent?

Related AI learning resources

Premium lesson notes and simulations | AI project templates | More Classical ML lessons