Lecture 3 - Linear Regression
Lecture 3 - Linear Regression
Since 2004
Hanoi, 09/2024
Outline
● Supervised Learning
● Linear Regression with One Variable
○ Model Representation
○ Cost Functions
○ Gradient Descent
● Linear Regression with Multiple Variables
○ Learning rate
○ Normal Equation
○ Output:
○ Training Data:
○ Hypothesis:
○ Hypothesis space:
FIT-CS INT3405 - Machine Learning 6
A Learning Problem
Unknown
Function
Input Output
Size (feet2)
Learning Algorithm y
Size of h Estimated x
house price
x Hypothesis y
Linear regression with one variable.
“Univariate Linear Regression”
Parameters:
y
Cost Function: mean squared error (MSE)
x
Goal:
Parameters:
Cost Function:
Goal:
Hypothesis:
Parameters:
Cost Function:
Goal:
Price ($)
in
1000’s
Outline:
• Start with some
• Keep changing to reduce
until we hopefully end up at a minimum
update
and
simultaneously
2104 5 1 45 460
1416 3 2 40 232
1534 3 2 30 315
852 2 1 36 178
… … … … …
Notation:
= number of features
= input (features) of training example.
= value of feature in training example.
FIT-CS INT3405 - Machine Learning 41
Multivariate Linear Regression (2)
Hypothesis:
Previously:
Parameters:
Cost function:
Gradient descent:
Repeat
Gradient Descent
Previously (n=1): New algorithm :
Repeat Repeat
(simultaneously update )
Declare convergence if
decreases by less than
in one iteration.
No. of iterations
For sufficiently small , should decrease on every iteration.
But if is too small, gradient descent can be slow to converge.
If is too large: may not decrease on every iteration; may not converge.
FIT-CS
SML– Term 1 2020-2021 INT3405 - Machine Learning 45
45
Learning Rate
divergenc
e
gradually decreased
too small too
constant large
● Analytical solution
1 2104 5 1 45 460
1 1416 3 2 40 232
1 1534 3 2 30 315
1 852 2 1 36 178
is inverse of matrix .
Duc-Trong Le
FIT-CS INT3405 - Machine Learning 53
Reading
To understand this lecture better: 3.1 to 3.2, ESL; 8.4, 11.2 PML
For next lectures: 5, 10 PML
Thank you