Lesson 8 - Regression-T
Lesson 8 - Regression-T
■ Duration: 2 hrs
■ Outline:
1. What is regression?
2. Simple linear regression
3. Example
Regression
■ Duration: 2 hrs
■ Outline:
1. What is regression?
2. Simple linear regression
3. Example
Regression
What is regression analysis?
■ Duration: 2 hrs
■ Outline:
1. What is regression?
2. Simple linear regression
3. Example
Objectives
Linear model: straight line of best fit through the data points
y-axis
(x2, y2)
(x1, y1)
x-axis
0 Give two point (x1, y1) and (x2, y2)
How to "develop" an equation connecting these two points?
13
Simple linear regression model
y-axis
(x2, y2)
(x1, y1)
x-axis
0 • Find gradient (slope):
• Find (intercept) (initial coefficient of y when x=0)
16 14
Simple linear regression model
intercept y f x 1 x 0
slope
15
Simple linear regression model
Assumptions of simple linear regression
Linearity: the line of best fit through the data points is a straight
line, rather than a curve or some sort of grouping factor.
Assumptions of simple linear regression
Simple linear regression problem
■ Duration: 2 hrs
■ Outline:
1. What is regression?
2. Simple linear regression
3. Example
Restaurant tipping 1
bill amount
amount
SSE = 120 = SST SSE = 30.075
Solving Linear Regression Using Gradient
Descent
Gradient Descent is an optimization algorithm used to find the
best values of β0 (intercept) and β1 (slope) by minimizing the
Mean Squared Error (MSE).
These gradients tell us the direction in which we should update β0 and β1.
Basic idea
• Initialize β1
• Repeat until convergence
simultaneous update
β1 ➛ β1 β1
β1 for j = 0 ... d
2
J(β1)
1
0
-0.5 0 0.5 1 1.5 2 2.5
β1
How to improve the model?
f x w0 w1 x1 w2 x2 w p x p
w w0 , w1 , w2 , , w p
T
x 1, x1 , x2 , , x p
f x xw
Loss
function
Polynomial Regression
Overfitting
Overfitting if:
Error
y Model complexity y
2 x x
Underfitting and overfitting illustrated
Underfitting and overfitting illustrated
Exercise 1
Predicting weight from height.