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
What quantity does linear regression minimise, and what are and ?
Answer
- Short answer: It minimises the sum of squared residuals ; is the intercept and is the slope.
- Why: Least squares β the parameters that make predictions closest (in squared error) to the observed .
What does a learning curve show, and what happens to MSE as data grows?
Answer
- Short answer: A learning curve plots error (MSE) against training-set size; MSE decreases as more data is added (better fit).
- Why: More data β closer to truth β the fit converges toward the true model (rate depends on the algorithm).