Interactive Linear Regression Playground

Click or tap on the canvas to add data points. The cyan line shows the ordinary least squares fit. Watch weight, bias, and MSE update instantly.

Linear regression minimizes the sum of squared residuals. For points \((x_i, y_i)\), we solve for \(w\) and \(b\) in \(\hat{y} = wx + b\):

\[ w = \frac{n\sum x_i y_i - \sum x_i \sum y_i}{n\sum x_i^2 - (\sum x_i)^2}, \quad b = \bar{y} - w\bar{x} \]

Click to add points — the regression line appears after 2 points.

Weight (w)
0
Bias (b)
0
MSE
0
Points
0

How to Use This Tool

  1. Add at least two points to see the regression line appear.
  2. Try outliers — notice how MSE increases and the line shifts.
  3. Use "Load Sample Data" for a noisy linear trend.
  4. Compare your intuition with the formulas in ML Beginner.