Lecture365
Lecture365
Regression
with
mul2ple
variables
Mul2ple features
Machine
Learning
Mul4ple
features
(variables).
Andrew
Ng
Mul4ple
features
(variables).
Size
(feet2)
Number
of
Number
of
Age
of
home
Price
($1000)
bedrooms
floors
(years)
2104
5
1
45
460
1416
3
2
40
232
1534
3
2
30
315
852
2
1
36
178
…
…
…
…
…
Nota2on:
=
number
of
features
=
input
(features)
of
training
example.
=
value
of
feature
in
training
example.
Andrew
Ng
Hypothesis:
Previously:
Andrew
Ng
For
convenience
of
nota2on,
define
.
Gradient
descent:
Repeat
(simultaneously update )
Andrew
Ng
Linear
Regression
with
mul2ple
variables
Gradient
descent
in
prac2ce
I:
Feature
Scaling
Machine
Learning
Feature
Scaling
Idea:
Make
sure
features
are
on
a
similar
scale.
E.g.
=
size
(0-‐2000
feet2)
size
(feet2)
=
number
of
bedrooms
(1-‐5)
number
of
bedrooms
Andrew
Ng
Feature
Scaling
Get
every
feature
into
approximately
a
range.
Andrew
Ng
Mean
normaliza4on
Replace
with
to
make
features
have
approximately
zero
mean
(Do
not
apply
to
).
E.g.
Andrew
Ng
Linear
Regression
with
mul2ple
variables
Andrew
Ng
Making
sure
gradient
descent
is
working
correctly.
Example
automa2c
convergence
test:
To choose , try
Andrew
Ng
Linear
Regression
with
mul2ple
variables
Features
and
polynomial
regression
Machine
Learning
Housing
prices
predic4on
Andrew
Ng
Polynomial
regression
Price
(y)
Size (x)
Andrew
Ng
Choice
of
features
Price
(y)
Size (x)
Andrew
Ng
Linear
Regression
with
mul2ple
variables
Normal equa2on
Machine
Learning
Gradient
Descent
Andrew
Ng
Intui2on:
If
1D
(for every )
Solve
for
Andrew
Ng
Examples:
Size
(feet2)
Number
of
Number
of
Age
of
home
Price
($1000)
bedrooms
floors
(years)
1
2104
5
1
45
460
1
1416
3
2
40
232
1
1534
3
2
30
315
1
852
2
1
36
178
Andrew
Ng
examples
;
features.
E.g. If
Andrew
Ng
is
inverse
of
matrix
.
Octave: pinv(X’*X)*X’*y
Andrew
Ng
training
examples,
features.
Gradient
Descent
Normal
Equa2on
• Need
to
choose
.
• No
need
to
choose
.
• Needs
many
itera2ons.
• Don’t
need
to
iterate.
•
Works
well
even
• Need
to
compute
when
is
large.
• Slow
if
is
very
large.
Andrew Ng