Optimization23 22
Optimization23 22
Gradient Descent in
ML
SLIDES FROM ANDREW NG
Let’s Learn a bit of ML
Linear Regression
Start with an example f i e d
i m pli
Predicting Housing prices in Hyderabad
l y s
s s
Gro ple
Size(x) Price(y) x a m
In Sqft INR in
We are given with some data in the form
of a Table with
e
L Notation:
x as size of houses in sft and
1100 199 y as the price in INR in Lakhs = Number of examples
= Input variable
1400 245
Task of ML is to learn the hidden = Output variable
1425 319 relationship between x, y and many (, ) = One training example
1550 240 other hidden features and to be able to
predict correctly. (, ) = training example
1600 312
1700 279
1700 310 If I want to buy a property of 2000 Sft, how much is the price?
1875 380
Given this data, a friend has a house 750 sft - how much can she be
2350 405 expected to get?"
2450 540
Predicting Housing prices in Hyderabad
𝑖=1
1700 279
1700 310
500 1000 1500 2000 2500
1875 380
2350 405
2450 540 Size in sft
Gradient descent for linear
regression
GD Step
Linear Regression is a finite-sum
optimization
𝑚
1 (𝑖) 2
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 𝐽 ( 𝜃 0 , 𝜃1 )=¿ ∑
2 𝑚 𝑖=1
( 𝑦 − ( 𝜃 0+𝜃 1 𝑥 ) ) ¿
(𝑖)
GD Step
Finite Sum
Optimization
Uses Full Training
Set
• + (+…+ (
• = +