Linear and Polynomial Regression

Context: FIT1043_MOC Β· a supervised regression method Β· fits an equation by minimising a loss Β· a real-valued predictive model Β· complexity governed by the bias–variance tradeoff

Quick Revision

  • 🎯 Objective: fit an equation to data βž” study a relationship and predict a real for a new .
  • πŸ“¦ Core Components: linear (intercept, slope) | polynomial = same machinery, higher degree.
  • ⚑ Key Constraint: the parameters are chosen to minimise the loss (MSE = mean squared residuals) over the training pairs β€” not to pass through every point.

πŸ“ How It Works

0. Terminology & When to Use

  • Regression βž” the study of the relationship between variables (e.g. salary ~ experience, education, role).
  • Independent variables βž” inputs / predictors (categorical or continuous), e.g. experience, education, role.
  • Dependent variable βž” output / response (continuous), e.g. salary.
  • Observation βž” one data point / row / sample.
  • When to use βž” (1) determine how variables relate (does education affect salary?); (2) forecast a value (electricity use given temperature/time/residents). Notation: Sales ~ TV + Radio + Newspaper.

1. Linear Regression

  • Model βž” β€” = intercept, = slope; a linear model (assumes a linear inputβ†’output relationship); one input β‡’ simple linear regression.
  • Best-fit aim βž” make the predicted response as close as possible to the actual response.
  • Residual βž” (actual βˆ’ predicted); positive above the line, negative below.
  • Fit (least squares / MSE) βž” choose minimising the loss; MSE is that loss averaged, telling how close the line is to the points:

2. Polynomial Regression

  • Motivation βž” if a straight line can’t capture the pattern (underfitting), increase model complexity by assuming a polynomial relationship.
  • Model βž” (degree/order ; the lecture fits up to a 10th-order polynomial).
  • Same infrastructure βž” reuses linear-regression machinery β€” still linear in the parameters β€” minimising the same squared-error loss over the data pairs.
  • Complexity has a cost βž” too high a degree overfits (see Bias-Variance Tradeoff (Underfitting vs Overfitting)).

3. More Data Improves the Fit

  • Trend βž” more training data β‡’ the fit approaches the true (pre-noise) model (e.g. 90 points fit better than 30).
  • Learning curve βž” a plot of error (MSE) vs training-set size; MSE decreases as data grows.
  • Algorithm-dependent βž” different algorithms show different decay rates on the learning curve.

πŸ“Š Exam Execution Trace

Applied Exercise

Problem: A fitted line is . Predict at , and give the residual if the actual . Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: prediction ; residual (actual sits just above the line).

⚠️ Common Mistakes

  • πŸ’‘ Higher degree β‰  better βž” a 10th-order polynomial can wiggle to chase noise; the goal is the loss-minimising fit that generalises, not one through every point.
  • πŸ’‘ β€œLinear” means linear in parameters βž” polynomial regression is still solved by linear-regression machinery because it’s linear in the coefficients .

🧠 Active Recall