You are on page 1of 21

Linear regression

with one variable

Model
representation
Machine Learning
500
Housing Prices
(Portland, OR) 400

300

Price 200
(in 1000s
of dollars) 100

0
0 500 1000 1500 2000 2500 3000
Size (feet2)

Supervised Learning Regression Problem


Given the “right answer” for Predict real-valued output
each example in the data.
Training set of Size in feet2 Price ($) in
housing prices (x) 1000's (y)
(Portland, OR) 2104 460
1416 232
1534 315
852 178
Notation: … …
m = Number of training examples
x’s = “input” variable / features
y’s = “output” variable / “target” variable
Training Set How do we represent h ?

Learning Algorithm

Size of Estimated
h
house price

Linear regression with one variable.


Univariate linear regression.
Linear regression
with one variable

Cost function

Machine Learning
Training Set Size in feet2 Price ($) in
(x) 1000's (y)
2104 460
1416 232
1534 315
852 178
… …
Hypothesis:

‘s: Parameters

How to choose ‘s ?
3 3 3

2 2 2

1 1 1

0 0 0
0 1 2 3 0 1 2 3 0 1 2 3
y

Idea: Choose so that


is close to for our
training examples
Linear regression
with one variable

Cost function
intuition I
Machine Learning
Simplified
Hypothesis:

Parameters:

Cost Function:

Goal:
(for fixed , this is a function of x) (function of the parameter )

3 3

2 2
y
1 1

0 0
0 1 2 3 -0.5 0 0.5 1 1.5 2 2.5
x
(for fixed , this is a function of x) (function of the parameter )

3 3

2 2
y
1 1

0 0
0 1 2 3 -0.5 0 0.5 1 1.5 2 2.5
x
(for fixed , this is a function of x) (function of the parameter )

3 3

2 2
y
1 1

0 0
0 1 2 3 -0.5 0 0.5 1 1.5 2 2.5
x
Linear regression
with one variable

Cost function
intuition II
Machine Learning
Hypothesis:

Parameters:

Cost Function:

Goal:
(for fixed , this is a function of x) (function of the parameters )

500

400

Price ($)
in 1000’s 300

200

100

0
0 1000 2000 3000
Size in feet2 (x)
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )

You might also like