Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmAnimated walkthrough

Multiple Linear Regression

Linear regression with several input features at once.

The idea

The prediction is a weighted sum of all features plus a bias, so the fitted shape is a plane (or hyperplane) instead of a line. Each weight tells you the effect of its feature while holding the others fixed. Features on very different scales should be standardised.

ŷ = w₀ + w₁x₁ + … + wₙxₙ

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Arrange the data as a matrix X with one column per feature.
  2. 2Add a column of ones for the intercept.
  3. 3Solve w = (XᵀX)⁻¹Xᵀy or use gradient descent.
  4. 4Predict with ŷ = Xw.

ŷ = w₀ + w₁x₁ + … + wₙxₙ

1/4

Step by step

  1. 1Arrange the data as a matrix X with one column per feature.
  2. 2Add a column of ones for the intercept.
  3. 3Solve w = (XᵀX)⁻¹Xᵀy or use gradient descent.
  4. 4Predict with ŷ = Xw.

Where it is used

House prices, sales forecasting, scientific modelling.

Watch out for

Highly correlated features (multicollinearity) make weights unstable; regularisation helps.

Related