ML Visual Lab

Regression

Linear Regression

See how slope and intercept define a line, and how residuals contribute to mean squared error.

Teaching dataset 9 observations · 2D

Fit the line

Adjust m and b, then find the least-squares fit.
0.50
2.00
Unfitted · manual line

Model and residuals

Vertical segments show each observation's error.
Linear regression plot A scatter plot with observations, residuals, and a regression line.
Training observation Residual Current model Inference projection

Current model metrics

Mean squared error MSE Average squared residual
Current slope m 0.50
Current intercept b 2.00

What's Happening?

Adjust the slope or intercept. The residuals and MSE will update immediately.

Formula

The line predicts a value for each X, then averages the squared vertical errors.

Predictionŷ = 0.50x + 2.00
Residualrᵢ = yᵢ − ŷᵢ
Mean squared errorMSE = (1 / n) Σ (yᵢ − ŷᵢ)²

Inference

After fitting, select a new X value to project it onto the current line.

Prediction on unseen input
6.50
Predicted ŷ

Fit the model first to enable inference.