W1.2 Regression 1
W1.2 Regression 1
Dr Chao Liu
2/55
Embrace the error!
3/55
Agenda
Recap
Summary
4/55
Machine learning
5/55
Machine learning
taxonomy
Machine
Learning
Supervised Unsupervised
Density Structure
Classification Regression
Estimation Analysis
6/55
Agenda
Recap
Summary
7/55
Problem formulation
8/55
Examples of regression
problems
The following are examples of business and scientific problems that can
be formulated as a regression problem:
Predict the energy consumption of a household, given the location
of the house, household size, income, intensity of occupation.
Predict future values of a company stock, given past stock prices.
Predict distance driven by a vehicle given its speed and journey
duration.
Predict demand given past demand and currency exchange rate.
Predict tomorrow’s temperature given today’s temperature and
pressure.
Predict the probability to develop a specific heart condition given
BMI, alcohol consumption, diet, number of daily steps.
Can you identify labels and predictors? Do we need data to solve them?
9/55
Predictors and labels
In this dataset:
Age Salary
S1 18 12000
S2 37 68000 (a) Age is the predictor, Salary is
S3 66 80000 the label
S4 25 45000 (b) Salary is the predictor, Age is
S5 26 30000 the label
... ... ... (c) Both options can be considered
10/55
Association and causation
11/55
Mathematical notation
xi f (⋅) yˆi
Population:
x is the predictor attribute
y is the label attribute
Dataset:
N is the number of samples, i identifies each sample
x i is the predictor of sample i
y i is the actual label of sample i
( x i , y i ) is sample i, {(x i , y i ) ∶ 1 ≤ i ≤ N } is the entire dataset
Model:
f (⋅) denotes the model
yˆi=f( x i ) is the predicted label for sample i
y i − yˆi is the prediction error for sample i
12/55
Candidate solutions
20 30 40 50 60 70
Age [years]
13/55
What is a good model?
Two quality metrics based on the squared error are the sum of squared
errors (SSE) and the mean squared error (MSE), which can be computed
using a dataset as:
14/55
MSE: Example
15/55
A zero-error model?
Given a dataset, is it possible to find a model such that yˆi=y i for every
instance i in the dataset, i.e. a model whose error is zero, E M S E = 0?
16/55
The nature of the error
There will always be some discrepancy (error e) between the true label y
and our model prediction f (x). Embrace the error!
17/55
Regression as an optimisation problem
The question is, how do we find such model? Finding such a model is an
optimisation problem.
Note that we are defining regression as finding the model that minimises
E M S E on the dataset, without considering what happens once deployed.
18/55
Agenda
Recap
Summary
19/55
Our regression
learner
Priors
Learner
Data
Model
20/55
Simple
regression
Simple regression considers one predictor x and one label y.
Salary
20 30 40 50 60 70
Age [years]
21/55
Simple linear
regression
22/55
Linear solution: Example
Salary
10 20 30 40 50 60 70 80
Age [years]
23/55
Beyond linearity
Sketch the model that you would choose for the Salary Vs Age dataset
and try to find a suitable mathematical expression.
Salary
20 30 40 50 60 70
Age [years]
24/55
Simple polynomial
regression
25/55
Quadratic solution
Salary
20 30 40 50 60 70
Age [years]
26/55
Cubic solution
Salary
20 30 40 50 60 70
Age [years]
27/55
5-power
solution
Salary
20 30 40 50 60 70
Age [years]
28/55