Linear regression

Linear Regression

Supervised Learning

Definition

A model that predicts a continuous numeric value as a weighted sum of the features: ŷ = w₀ + w₁x₁ + … + wₙxₙ.

Core idea

We look for the line (or plane) that makes the sum of squared differences between the true and predicted values as small as possible (Least Squares).

ŷ
Data points and a regression line that minimises the sum of squared residuals (the vertical lines).

How it works

  1. We choose the numeric features and encode the categorical ones
  2. We compute the weights that minimize the sum of squared errors
  3. Each weight is how much the target changes when the feature increases by one unit, holding the others fixed
  4. We evaluate on test data with regression metrics

Data type and problem type

Data typeNumeric tabular data (categorical after encoding)
Problem typeRegression

Strengths

  • Fast, simple and interpretable
  • An excellent baseline
  • Does not need much data

Limitations

  • Assumes a linear relationship
  • Sensitive to outliers
  • Affected by high correlation between features (Multicollinearity)

Key parameters

  • Regularization: Ridge (L2) or Lasso (L1) and its strength
  • Adding a constant term (Intercept)

Evaluation metrics

  • MAE (mean absolute error)
  • RMSE (root mean squared error)
  • R² (coefficient of determination)

Supporting tools

OrangeLinear Regression
KNIMELinear Regression Learner + Regression Predictor
WEKAfunctions.LinearRegression

Applied examples

  • Estimating a student's grade from study hours
  • Estimating the price of a house from its area and location
  • Estimating a penguin's body mass from its measurements

Related projects

Alternative algorithms

Try it in the lab