Professional Documents
Culture Documents
Welcome
Machine Learning
Machine Learning
- Grew out of work in AI
- New capability for computers
Examples:
- Database mining
Large datasets from growth of automation/web.
E.g., Web click data, medical records, biology, engineering
- Applications can’t program by hand.
E.g., Autonomous helicopter, handwriting recognition, most of
Natural Language Processing (NLP), Computer Vision.
Andrew Ng
Machine Learning
- Grew out of work in AI
- New capability for computers
Examples:
- Database mining
Large datasets from growth of automation/web.
E.g., Web click data, medical records, biology, engineering
- Applications can’t program by hand.
E.g., Autonomous helicopter, handwriting recognition, most of
Natural Language Processing (NLP), Computer Vision.
- Self-customizing programs
E.g., Amazon, Netflix product recommendations
- Understanding human learning (brain, real AI).
Andrew Ng
Introduction
What is machine
learning
Machine Learning
Andrew Ng
Machine Learning definition
• Arthur Samuel (1959). Machine Learning: Field of
study that gives computers the ability to learn
without being explicitly programmed.
• Tom Mitchell (1998) Well-posed Learning
Problem: A computer program is said to learn
from experience E with respect to some task T
and some performance measure P, if its
performance on T, as measured by P, improves
with experience E.
Andrew Ng
“A computer program is said to learn from experience E with respect to
some task T and some performance measure P, if its performance on T,
as measured by P, improves with experience E.”
Suppose your email program watches which emails you do or do
not mark as spam, and based on that learns how to better filter
spam. What is the task T in this setting?
Andrew Ng
Introduction
Supervised
Learning
Machine Learning
Andrew Ng
Housing price prediction.
400
300
0
0 500 1000 1500 2000 2500
Size in feet2
Tumor Size
Andrew Ng
- Clump Thickness
- Uniformity of Cell Size
Age - Uniformity of Cell Shape
…
Tumor Size
Andrew Ng
You’re running a company, and you want to develop learning algorithms to address each
of two problems.
Problem 1: You have a large inventory of identical items. You want to predict how many
of these items will sell over the next 3 months.
Problem 2: You’d like software to examine individual customer accounts, and for each
account decide if it has been hacked/compromised.
Andrew Ng
Supervised Learning
x2
x1
Andrew Ng
Unsupervised Learning
x2
x1
Andrew Ng
Andrew Ng
Andrew Ng
Genes
Individuals
Individuals
Size (feet2)
Supervised Learning Regression Problem
Given the “right answer” for Predict real-valued output
each example in the data.
21
Andrew Ng
Training set of Size in feet2 (x) Price ($) in 1000's (y)
housing prices 2104 460
(Portland, OR) 1416 232
1534 315
852 178
… …
Notation:
m = Number of training examples
x’s = “input” variable / features
y’s = “output” variable / “target” variable
22
Andrew Ng
Training Set How do we represent h ?
Learning Algorithm
Size of h Estimated
house price
Machine Learning
24
Andrew Ng
Size in feet2 (x) Price ($) in 1000's (y)
Training Set
2104 460
1416 232
1534 315
852 178
… …
Hypothesis:
‘s: Parameters
How to choose ‘s ?
25
Andrew Ng
3 3 3
2 2 2
1 1 1
0 0 0
0 1 2 3 0 1 2 3 0 1 2 3
26
Andrew Ng
y
Parameters:
Cost Function:
Goal:
29
Andrew Ng
(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
30
Andrew Ng
(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
31
Andrew Ng
(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
32
Andrew Ng
Linear regression
with one variable
Gradient
Machine Learning
descent
42
Andrew Ng
Have some function
Want
Outline:
• Start with some
• Keep changing to reduce
until we hopefully end up at a minimum
43
Andrew Ng
J(0,1)
1
0
44
Andrew Ng
J(0,1)
1
0
45
Andrew Ng
Gradient descent algorithm
46
Andrew Ng
Linear regression
with one variable
Gradient descent
intuition
Machine Learning
47
Andrew Ng
Gradient descent algorithm
48
Andrew Ng
49
Andrew Ng
If α is too small, gradient descent
can be slow.
50
Andrew Ng
at local optima
Current value of
51
Andrew Ng
Gradient descent can converge to a local
minimum, even with the learning rate α fixed.
As we approach a local
minimum, gradient
descent will automatically
take smaller steps. So, no
need to decrease α over
time. 52
Andrew Ng
53
Andrew Ng
Linear regression
with one variable
Gradient descent for
linear regression
Machine Learning
54
Andrew Ng
Gradient descent algorithm Linear Regression Model
55
Andrew Ng
56
Andrew Ng
Gradient descent algorithm
update
and
simultaneously
57
Andrew Ng
J(0,1)
1
0
58
Andrew Ng
60
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
61
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
62
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
63
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
64
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
65
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
66
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
67
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
68
Andrew Ng
(for fixed , this is a function of x) (function of the parameters )
69
Andrew Ng
“Batch” Gradient Descent
70
Andrew Ng