0% found this document useful (0 votes)
28 views

Week 7

The document discusses machine learning concepts like image recognition, natural language processing, and nearest neighbor classifiers. It provides examples of how machine learning algorithms can be used for tasks like image classification, handwritten digit recognition, and text clustering. The document also discusses challenges in machine learning like dealing with high dimensional data and improving performance on complex tasks like autonomous driving.

Uploaded by

motro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Week 7

The document discusses machine learning concepts like image recognition, natural language processing, and nearest neighbor classifiers. It provides examples of how machine learning algorithms can be used for tasks like image classification, handwritten digit recognition, and text clustering. The document also discusses challenges in machine learning like dealing with high dimensional data and improving performance on complex tasks like autonomous driving.

Uploaded by

motro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

CS50

Machine Learning
Week 7
*pythonprogramming.net
Machine Learning?
Machine Learning?

Search Image Voice Natural


Engines Recognition Recognition Language
Processing
inputs outputs
Image Recognition

horse
car
Natural Language Processing

Nineteen Eighty-Four
by George Orwell
(1984)
[...]
Politics
BIG BROTHER Propaganda
IS WATCHING
YOU, the caption
Privacy
said, while the
dark eyes looked
deep into
Winston's own
[...]
Whodunit!

Image recognition

horse
car
Machine Learning algorithms

Training
inputs data outputs
Machine Learning algorithms

Training
data horse
Image Classification
0
1
2
3
4
5
6
7
8
9
Handwritten digit classification

Training 0
data

0
1
6
2
3
4
5
6
7
8
9
Nearest
Neighbor Minimal
Classifier distance

0 00 ? 6 66
Labeled training set Test point
Nearest
Neighbor 6
Classifier 6
? 6
0 6
0 Minimal
0 distance

Labeled training set Test point


?
Nearest
Neighbor
Classifier
6
6
? 6
0 6
0 Minimal
0 distance

Labeled training set Test point


?
Flatland
by Edwin Abbott Abbott
(1884)

*www.wikipedia.com
Flatland, Edwin Abbott Abbott, 1984

Flatland: The story describes a two-dimensional world occupied by


geometric figures. The narrator is a square named A Square who guides the
readers through some of the implications of life in two dimensions.
On New Year's Eve, A Square dreams about a visit to a one-dimensional
world (Lineland) inhabited by "lustrous points", in which he attempts to convince
the realm's monarch of a second dimension; but is unable to do so.
Following this vision, A Square is himself visited by a three-dimensional
sphere named A Sphere, which he cannot comprehend until he sees Spaceland
(a tridimensional world)

https://vimeo.com/8675372
*www.wikipedia.com
Ready to go beyond
Lineland, Flatland, and
Spaceland?
?
0 0 5 13 9 1 0 0
0 0 13 15 10 15 5 0
0 3 15 2 0 11 8 0
0 4 12 0 0 8 8 0
0 5 8 0 0 9 8 0
0 4 11 0 1 12 7 0
0 2 14 5 10 12 0 0
0 0 6 13 10 0 0 0
0 0 5 13 9 1 0 0
0 0 13 15 10 15 5 0
0 3 15 2 0 11 8 0
0 4 12 0 0 8 8 0
0 5 8 0 0 9 8 0
0 4 11 0 1 12 7 0
0 2 14 5 10 12 0 0
0 0 6 13 10 0 0 0

64 dimensional space
Nearest
Neighbor
Classifier
6
6
? 6
0 6
0 dist( , )
0

Labeled training set Test point


dist( , )
dist( , ) = 31.98
0 0 5 13 9 1 0 0 0 0 2 12 4 0 0 0
0 0 13 15 10 15 5 0 0 1 12 16 16 3 0 0
0 3 15 2 0 11 8 0 0 7 16 6 4 13 0 0
0 4 12 0 0 8 8 0 0 8 16 6 0 13 5 0
0 5 8 0 0 9 8 0 0 1 16 5 0 7 9 0
0 4 11 0 1 12 7 0 0 0 16 8 0 8 12 0
0 2 14 5 10 12 0 0 0 0 13 14 14 16 10 0
0 0 6 13 10 0 0 0 0 0 4 14 15 7 0 0
dist( , )
dist( , ) = 45.97
0 0 5 13 9 1 0 0 0 0 4 14 5 0 0 0
0 0 13 15 10 15 5 0 0 0 13 14 0 0 0 0
0 3 15 2 0 11 8 0 0 2 16 10 0 0 0 0
0 4 12 0 0 8 8 0 0 4 16 7 0 0 0 0
0 5 8 0 0 9 8 0 0 6 16 16 15 4 0 0
0 4 11 0 1 12 7 0 0 4 16 9 4 16 2 0
0 2 14 5 10 12 0 0 0 1 15 13 6 16 11 0
0 0 6 13 10 0 0 0 0 0 4 13 16 15 5 0
The digits dataset
0
1
2 Labeled
3 training
4
5
set
6
7
8
9
Python code
(Supervised Learning)
np.sqrt(np.sum((x - y)**2)) ???

x = [1, 1]
y = [3, 4]
x - y = [-2, -3]
(x - y)**2 = [4, 9]
np.sum((x - y)**2) = 13
np.sqrt(np.sum((x - y)**2)) = 3.60
0
1
2
3 Labeled
4
5 training
6
7
set
8
9

Labeled Test point


Training subset
0
1
2
3
4
5
6
7
8
9

Labeled Testing set


Training set
0
1
2
3
4
5
6
7
8
9

Labeled Testing set


Training set
With Nearest Neighbor Classifier

0
6
~ 97% Correct
The CIFAR-10 dataset
airplane
automobile
bird
cat Labeled
deer training set
dog
frog
horse www.kaggle.com
ship
truck
*http://www.cs.toronto.edu/~kriz/cifar.html
With Nearest Neighbor Classifier

horse
car

~ 30% Correct
Training set for category ‘0’:

Training set for category ‘horse’:


Challenges

*http://cs231n.github.io
Features

0 0 5 13 9 1 0 0
0 0 13 15 10 15 5 0
0 3 15 2 0 11 8 0
0 4 12 0 0 8 8 0
0 5 8 0 0 9 8 0
0 4 11 0 1 12 7 0
0 2 14 5 10 12 0 0
0 0 6 13 10 0 0 0
Features

(, , ,)
Deep
Learning

*http://www.slideshare.net/roelofp/220115dlmeetup
Tensorflow Deep dream generator

https://www.tensorflow.org http://deepdreamgenerator.com
The CIFAR-10 dataset
airplane
automobile
bird
cat Labeled
deer training set
dog
frog
horse
ship
truck
*http://www.cs.toronto.edu/~kriz/cifar.html
With Deep Learning...

horse
car

~ 95% Correct
Is 95% enough?
MAY 2016

http://wapo.st/2981upr
“Neither Autopilot nor the driver noticed the white side
of the tractor trailer against a brightly lit sky, so the
brake was not applied”

*www.tesla.com
Challenges

*http://cs231n.github.io
Text Clustering
Text clustering

IMDB synopses for: CLUSTER 1:


- ???
A Beautiful Mind
- Robin Hood
- ???
The Matrix
- The Matrix
- ???
The King's Speech
- The King's Speech
- Aladdin
CLUSTER 2:
- A Beautiful Mind
- ???
Robin Hood
- Finding Nemo
- ???
Aladdin
- ???
Finding Nemo

k=2
https://docs.google.com/spreadsheets/d/1udJ4nd9EKlX_awB90JCbKaStuYh6aVjh1X6j8iBUXIU/edit#gid=0
k=2 Unlabeled data

K-means
k=2 Unlabeled data

K-means
Robin Hood
Told with animals for it's
cast, the story tells of
? Robin Hood
Robin Hood (a fox) and
Little John (a brown
bear), who rob from the
rich to give to the poor.
[...]
Unlabeled data
k=2
A Beautiful Mind

The Matrix
Aladdin The King's Speech
Robin Hood
Finding Nemo

K-means
Something simpler...
a) I love CS50. Staff is
awesome, awesome,
awesome!
CLUSTER 1:
b) I have a dog and a cat.
a) c)
c) Best of CS50? Staff.
And cakes. Ok, CS50 staff. CLUSTER 2:
b) d)
d) My dog keeps chasing my
cat. Dogs!

k=2
k=2
b) I have a dog and a cat.

d) My dog keeps chasing


my cat. Dogs!
a) I love CS50. Staff is
awesome, awesome,
awesome!

c) Best of CS50? Staff.


And cakes. Ok, CS50 staff.

K-means
a) I love CS50. Staff is
awesome, awesome,
? a) I love CS50. Staff is
awesome, awesome,
awesome!
awesome!
a) I love CS50. Staff is awesome, awesome, awesome!
b) I have a dog and a cat.
c) Best of CS50? Staff. And cakes. Ok, CS50 staff.
Bags of
d) My dog keeps chasing my cat. Dogs! words
awesome best cakes cat chasing cs50 dog dogs keeps love ok staff

a) 3 0 0 0 0 1 0 0 0 1 0 1
b) 0 0 0 1 0 0 1 0 0 0 0 0
c) 0 1 1 0 0 2 0 0 0 0 1 2
d) 0 0 0 1 1 0 1 1 1 0 0 0
a) I love CS50. Staff is awesome, awesome, awesome!
b) I have a dog and a cat.
c) Best of CS50? Staff. And cakes. Ok, CS50 staff.
d) My dog keeps chasing my cat. Dogs!
Frequency

awesome best cakes cat chasing cs50 dog dogs keeps love ok staff

a) 3/6 0 0 0 0 1/6 0 0 0 1/6 0 1


b) 0 0 0 1/2 0 0 1/2 0 0 0 0 0
c) 0 1/7 1/7 0 0 2/7 0 0 0 0 1/7 2/7
d) 0 0 0 1/5 1/5 0 1/5 1/5 1/5 0 0 0
a) I love CS50. Staff is a) I love CS50. Staff is
awesome, awesome,
awesome, awesome, awesome!
awesome!
(3/6, 0, 0, 0, 0, 1/6, 0, 0, 0, 1/6, 0, 1)

12 dimensional space
k=2
b) I have a dog and a cat.

d) My dog keeps chasing


my cat. Dogs!
a) I love CS50. Staff is
awesome, awesome,
awesome!

c) Best of CS50? Staff.


And cakes. Ok, CS50 staff.

K-means
Python code
(Unsupervised Learning)
Recap
Handwritten digit classification

0
6
Text clustering

IMDB synopses for: CLUSTER 1:


- A Beautiful Mind
- Robin Hood
- The Matrix
- The Matrix
- The King's Speech
- The King's Speech
- Aladdin
CLUSTER 2:
- A Beautiful Mind
- Robin Hood
- Finding Nemo
- Aladdin
- Finding Nemo

k=2
https://docs.google.com/spreadsheets/d/1udJ4nd9EKlX_awB90JCbKaStuYh6aVjh1X6j8iBUXIU/edit#gid=0
Machine Learning?

Search Image Voice Natural


Engines Recognition Recognition Language
Processing
Machine Learning… so much more

# #
## ##
### ###
#### ####
##### #####
###### ######
####### #######
Machine Learning… so much more

MARCH 2016
“Commentators were convinced [AlphaGo]
had made mistakes, but as it racked up
wins, they were forced to concede that
perhaps the machine [...] was using
strategies its human masters had
simply overlooked.”

Lee Sedol *www.economist.com

https://www.youtube.com/watch?v=JNrXgpSEEIE&t=0m30s

You might also like