CV Lecture 11

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 147

Computer Vision

CSC-455
Muhammad Najam Dar
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Classifier Performance
• Decision Trees
• Audio & Speech Recognition
Classification system

Feature Extractor
Camera (Image Processing) Classifier
Image Analysis

Typical steps:
• Pre-processing
• Segmentation (object
detection)
• Feature extraction
• Feature selection
• Classifier training
• Evaluation of classifier
performance.
Feature types (regional features)

• Colour features
• Gray level
features
• Shape features
• Histogram
(texture) features
Techniques for Image Features
Extraction
• Hough Transform
• Corners
• Shape features
• GLCM
• HOG
• SIFT
• SURF
• Gabor and Wavelet
• LBP
Techniques for Image Features
Extraction
• Hough Transform
• Corners
• Shape features
• GLCM
• HOG
• SIFT
• SURF
• Gabor and Wavelet
• LBP
Properties of Shape Features

•Identifiability: perceptually similar objects have


similar (or the same) features.
•Translation, rotation and scale invariance: the
location, the rotation and the scaling changing of the
shape must not affect the extracted features.
1. Center of Gravity
• The center of gravity is also called centroid. Its
position should be fixed in relation to the shape.
2. Circularity ratio
• Circularity ratio represents how a shape
is similar to a circle.
• Circularity ratio is the ratio of the area
of a shape to the shape's perimeter
square:
3. Rectangularity
• Rectangularity represents how rectangular a
shape is, i.e. how much it fills its minimum
bounding rectangle:

• where AS is the area of a shape; AR is the


area of the minimum bounding rectangle.
4. Convexity
• Convexity is defined as the ratio of
perimeters of the convex hull over that of
the original contour.
1

3
5. Solidity
• Solidity describes the extent to which the
shape is convex or concave.

• where, As is the area of the shape region and


H is the convex hull area of the shape. The
solidity of a convex shape is always 1.

14
6. Euler number
• Euler number describes the relation between
the number of contiguous parts and the
number of holes on a shape. Let S be the
number of contiguous parts and N be the
number of holes on a shape. Then the Euler
number is:
Texture Analysis: GLCM Features
Computation of Co-occurrence Matrix
- It has size N×N (N = Number of gray-values) i.e., the
rows & columns represent the set of possible pixel
values.

- It is computed based on two parameters:

d  Relative distance between the pixel pair


(measured in pixel number. e.g., 1, 2, …)
θ  Relative orientation / rotational angle.
(e.g., 0º, 45º, 90º, 135º, …)
8 Directions/orientations (θ) of Adjacency

In this thesis, we consider θas horizontal , front diagonal ,


vertical and back diagonal
Computation of Co-occurrence Matrix

Image matrix Find the number of co-occurrences of


0 0 1 1 pixel i to the neighboring pixel value j
0 0 1 1 i/j 0 1 2 3

0 2 2 2 0 #(0,0) #(0,1) #(0,2) #(0,3)


2 2 3 3
1 #(1,0) #(1,1) #(1,2) #(1,3)

Pixel values: 0,1,2,3. So,N= 4


2 #(2,0) #(2,1) #(2,2) #(2,3)
So, size of CM = 4x4
3 #(3,0) #(3,1) #(3,2) #(3,3)
d=1
θ = horizontal
d=1 θ = horizontal
i/j 0

0 #(0,0)

0 0 1 1 2
0 0 1 1
0 2 2 2
2 2 3 3
Example: Computation (contd.)

0 0 1 1 2 2 1 0
0 0 1 1
Image
0 2 2 2
2 2 3 3
i/j 0 1 2 3 CM for the Image

0 #(0,1) #(0,2) #(0,3) d=1 θ = horizontal

3
Example: Computation (contd.)

0 0 1 1 2 2 1 0
0 0 1 1 0 2 0 0
Image 0 0 3 1
0 2 2 2
2 2 3 3 0 0 0 1
i/j 0 1 2 3
CM for the Image

0 #(0,0) #(0,1) #(0,2) #(0,3) d=1 θ = horizontal

1 #(1,0) #(1,1) #(1,2) #(1,3)

2 #(2,0) #(2,1) #(2,2) #(2,3)

3 #(3,0) #(3,1) #(3,2) #(3,3)


Example: Computation (contd.)

0 0 1 1 3 0 2 0
0 0 1 1 0 2 2 0
Image 0 0 1 2
0 2 2 2
2 2 3 3 0 0 0 0
i/j 0 1 2 3
CM for the Image

0 #(0,0) #(0,1) #(0,2) #(0,3)


d=1 θ = vertical
1 #(1,0) #(1,1) #(1,2) #(1,3)

2 #(2,0) #(2,1) #(2,2) #(2,3)

3 #(3,0) #(3,1) #(3,2) #(3,3)


Features on co-occurrence matrix
- Co-occurrence matrices capture properties of a texture
- But they are not directly useful for further analysis
(e.g., comparison of two textures)

11 Numeric features are computed from a matrix


Features on co-occurrence matrix (contd.)

Co-occurrence Matrices

(d,θ) = (1,)
Angular Second Moment (ASM) feature
Input image Contrast feature Feature
Entropy feature Vector
(d,θ) = (1,) Variance feature
Correlation feature
Inverse Difference Moment (IDM) feature
Sum Average feature
Sum Variance feature
(d,θ) = (1,) Sum Entropy feature
Information Measures of Correlation feature – 1
Information Measures of Correlation feature – 2

(d,θ) =(1,)
ENERGY
• Also called Uniformity or Angular second moment.
• Measures the textural uniformity that is pixel pair
repetitions.
• Detects disorders in textures.
• Energy reaches a maximum value equal to one.

𝐸𝑛𝑒𝑟𝑔𝑦 =∑ ∑ 𝑝
2
𝑖𝑗
𝑖 𝑗
Entropy

• Measures the disorder or complexity of an


image.
• The entropy is large when the image is not
texturally uniform.
• Complex textures tend to have high entropy.
• Entropy is strongly, but inversely correlated
to energy.


Contrast
• Measures the spatial frequency of an image
and is difference moment of GLCM.
• It is the difference between the highest and the
lowest values of a contiguous set of pixels.
• It measures the amount of local variations
present in the image.

• Contrast(con)=
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Classifier Performance
• Decision Trees
• Audio & Speech Recognition
Unsupervised Learning

x2

We need to figure out the patterns

x1
Supervised Learning

x2

We knew the correct answers

x1
Classification: Answers are
Categories
Person

Model Trained
Model
Fit

? Trained Predict if there is


a person in this
Model
Predict photo (yes | no)
Regression: Numeric Answers

movie data fit


+ model model
with
revenue

movie predict predicted


data + model revenue
(unknown
revenue)
Classification
What is
Classification?
Which flower is a customer
most likely to purchase based
on similarity to previous
purchase?

?
What is
Classification?
Which flower is a customer
most likely to purchase based
on similarity to previous
purchase?

?
What is
Classification?
Which flower is a customer
most likely to purchase based
on similarity to previous
purchase?

?
What is
Classification?
Which flower is a customer
most likely to purchase based
on similarity to previous
purchase?

?
Can we LEARN to recognise a rugby player?

What are the “features” of a rugby player?


Rugby players = short + heavy?

190cm

130cm

60kg 90kg
Ballet dancers = tall + skinny?

190cm

130cm

60kg 90kg
Rugby players “cluster” separately in the space.

Height

Weight
What is Needed for Classification?

• Model data with:


• Features that can be quantitated
• Labels that are known
• Method to measure similarity
Features
Machine Learning Vocabulary
• Target: predicted category or value of the data
(column to predict)
• Features: properties of the data used for
prediction (non-target columns)
• Example: a single data point within the data
(one row)
• Label: the target value for a single data point
Machine Learning Vocabulary
sepal length sepal width petal length petal width species

6.7 3.0 5.2 2.3 virginica

6.4 2.8 5.6 2.1 virginica

4.6 3.4 1.4 0.3 setosa


Target 6.9 3.1 4.9 1.5 versicolor

4.4 2.9 1.4 0.2 setosa

4.8 3.0 1.4 0.1 setosa

5.9 3.0 5.1 1.8 virginica

5.4 3.9 1.3 0.4 setosa

4.9 3.0 1.4 0.2 setosa

5.4 3.4 1.7 0.2 setosa


Machine Learning Vocabulary
sepal length sepal width petal length petal width species
6.7 3.0 5.2 2.3 virginica

6.4 2.8 5.6 2.1 virginica

4.6 3.4 1.4 0.3 setosa


Features 6.9 3.1 4.9 1.5 versicolor

4.4 2.9 1.4 0.2 setosa

4.8 3.0 1.4 0.1 setosa

5.9 3.0 5.1 1.8 virginica

5.4 3.9 1.3 0.4 setosa

4.9 3.0 1.4 0.2 setosa

5.4 3.4 1.7 0.2 setosa


Machine Learning Vocabulary
sepal length sepal width petal length petal width species

6.7 3.0 5.2 2.3 virginica

6.4 2.8 5.6 2.1 virginica

4.6 3.4 1.4 0.3 setosa


Example 6.9 3.1 4.9 1.5 versicolor
4.4 2.9 1.4 0.2 setosa

4.8 3.0 1.4 0.1 setosa

5.9 3.0 5.1 1.8 virginica

5.4 3.9 1.3 0.4 setosa

4.9 3.0 1.4 0.2 setosa

5.4 3.4 1.7 0.2 setosa


Machine Learning Vocabulary
sepal length sepal width petal length petal width species

6.7 3.0 5.2 2.3 virginica

6.4 2.8 5.6 2.1 virginica

4.6 3.4 1.4 0.3 setosa


Label 6.9 3.1 4.9 1.5 versicolor

4.4 2.9 1.4 0.2 setosa

4.8 3.0 1.4 0.1 setosa

5.9 3.0 5.1 1.8 virginica

5.4 3.9 1.3 0.4 setosa

4.9 3.0 1.4 0.2 setosa

5.4 3.4 1.7 0.2 setosa


Katydids

Given a collection of annotated


data. In this case 5 instances of
Katydids and five of Grasshoppers,
decide what type of insect the
Grasshoppers
unlabeled example is.

Katydid or Grasshopper?
For any domain of interest, we can measure
features
Color {Green, Brown, Gray, Has Wings?
Other}

Abdomen Thorax
Length Length Antennae
Length

Mandible
Size

Spiracle
Diameter
Leg Length
My_Collection
We can store
Insect Abdomen Antennae Insect Class
features in a ID Length Length
database. 1 2.7 5.5 Grasshopper
2 8.0 9.1 Katydid
3 0.9 4.7 Grasshopper
The classification
4 1.1 3.1 Grasshopper
problem can now be Katydid
5 5.4 8.5
expressed as: Grasshopper
6 2.9 1.9
7 6.1 6.6 Katydid
•Given a training database
(My_Collection), predict the class 8 0.5 1.0 Grasshopper
label of a previously unseen Katydid
instance
9 8.3 6.6
10 8.1 4.7 Katydids

previously unseen instance = 11 5.1 7.0 ???????


Grasshoppers Katydids

10
9
8
7
Antenna Length

6
5
4
3
2
1

1 4 5 8
Abdomen Length
6 9
2 7 10
We will return to the
previous slide in two minutes.
In the meantime, we are
going to play a quick game.

I am going to show you some


classification problems which
were shown to pigeons!

Let us see if you are as


smart as a pigeon!
Pigeon Problem 1
Examples of class A Examples of class
B

3 4 5 2.5

1.5 5 5 2

6 8 8 3

2.5 4.5
Pigeon Problem 1 What class is this
object?
Examples of class A Examples of class
B

3 4 5 2.5 8 1.5

What about this one,


1.5 5 5 2 A or B?

6 8 8 3

4.5
2.5 4.5
7
Pigeon Problem 1 This is a B!
Examples of class A Examples of class
B

3 4 5 2.5 8 1.5

1.5 5 5 2

Here is the rule.


If the left bar is
6 8 8 3
smaller than the
right bar, it is an A,
2.5 4.5 otherwise it is a B.
Pigeon Problem 2 Oh! This ones hard!

Examples of class A Examples of class


B

4 4 5 2.5 8 1.5

Even I know this one


5 5 2 5

6 6 5 3

7 7
3 3 2.5
Pigeon Problem 2
Examples of class A Examples of class
B

The rule is as follows, if the


two bars are equal sizes, it is
an A. Otherwise it is a B.
4 4 5 2.5

5 5 2 5

So this one is an A.

6 6 5 3

7 7
3 3 2.5
Pigeon Problem 3
Examples of class A Examples of class
B

6 6

4 4 5 6 This one is really hard!


What is this, A or B?

1 5 7 5

6 3 4 8

3 7 7 7
Pigeon Problem 3 It is a B!
Examples of class A Examples of class
B

6 6

4 4 5 6
The rule is as follows, if the
sum of the two bars is less
than or equal to 10, it is an
1 5 7 5
A. Otherwise it is a B.

6 3 4 8

3 7 7 7
10
Pigeon Problem 1 9
8
Examples of class A Examples of class 7
B 6

Left Bar
5
4
3
2
3 4 5 2.5 1

1 2 3 4
5 Bar
Right 6 7
8 9
1.5 5 5 2 10

Here is the rule again.


If the left bar is smaller
than the right bar, it is
6 8 8 3
an A, otherwise it is a B.

2.5 4.5
10
Pigeon Problem 2 9
8
Examples of class A Examples of class 7
B 6

Left Bar
5
4
3
2
4 4 5 2.5 1

1 2 3 4
5 Bar
Right 6 7
8 9
5 5 2 5 10
Let me look it up… here it is..
the rule is, if the two bars
are equal sizes, it is an A.
Otherwise it is a B.
6 6 5 3

3 3 2.5
100
Pigeon Problem 3 90
80
Examples of class A Examples of class 70
B 60

Left Bar
50
40
30
20
4 4 5 6 10

10 20 30 40 50 60 70 80 90 100
Right Bar
1 5 7 5

6 3 4 8 The rule again:


if the square of the sum of the
two bars is less than or
equal
3 7 7 7
to 100, it is an A. Otherwise it
Grasshoppers Katydids

10
9
8
7
Antenna Length

6
5
4
3
2
1

1 4 5 8
Abdomen Length
6 9
2 7 10
previously unseen instance = 11 5.1 7.0 ???????

•We can “project” the previously


10 unseen instance into the same
space as the database.
9
8 •We have now abstracted away the
details of our particular problem. It
7
Antenna Length

will be much easier to talk about


6 points in space.
5
4
3
2
1

1 4 5 8 Katydids
Abdomen Length
6 9 Grasshoppers
Nearest Neighbor Classifier

10
9
8
7
Antenna Length

6
5 If the nearest instance to the
4 previously unseen instance is a
Katydid
3 class is Katydid
2 else
class is
1
Grasshopper
Katydids
1 2 3 4 5 6 7 8 9 10 Grasshopper
Abdomen Length s
Simple Linear Classifier

10
9
8
7 R.A. Fisher
1890-1962
6
5 If previously unseen instance above the
4 line
then
3
class is Katydid
2 else
1 class is Grasshopper
Katydids
1 2 3 4 Grasshopper
5 6 7 s
Which of the “Pigeon Problems” can be solved by
the Simple Linear Classifier? 10
9
8
7
6
5
1) Perfect 4
2) Useless 3
3) Pretty Good 2
1

1 2 3

4 5

100 10 6 7 8
90 9 9 10
Problems that can 80 8
70 7
be solved by a linear 60 6
classifier are call 50 5
linearly separable. 40 4
30 3
20 2
10 1

10 20 30 40 50 60 70 80 90 100 1 2 3

4 5
BINARY vs MULTI-CLASS
CLASSIFICATION
Virginica
A Famous
Problem
R. A. Fisher’s Iris Dataset.

•• 350classes
of each class
Setosa
The task is to classify Iris
Versicolo
plants into one of 3 varieties
r
using the Petal Length and
Petal Width.

Iris Setosa Iris Iris Virginica


We can generalize the piecewise linear classifier to N classes, by fitting N-1 lines. In this
we
casefirst learned the line to (perfectly) discriminate between Setosa and
Virginica/Versicolor,
then we learned to approximately discriminate between Virginica and Versicolor.

Virginica

Setosa
Versicolor
Binary classification: Multi-class
classification:

x2 x2

x1 x1
x2
One-vs-all (one-vs-rest):

x1
x2 x2

x1
x1
x2
Class 1:
Class 2:
Class 3:

x1
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Classifier Performance
• Decision Trees
• Audio & Speech Recognition
K Nearest Neighbors Classification
60
Survived
Did not survive

40
Age

20

0 10

20
Number of Malignant Nodes
K Nearest Neighbors Classification
60

40
Age

Predict
20

0 10

20
Number of Malignant Nodes
K Nearest Neighbors Classification
Neighbor Count (K = 1): 0 1
60

40
Age

Predict
20

0 10

20
Number of Malignant Nodes
K Nearest Neighbors Classification
Neighbor Count (K = 2): 1 1
60

40
Age

Predict
20

0 10

20
Number of Malignant Nodes
K Nearest Neighbors Classification
Neighbor Count (K = 3): 2 1
60

40
Age

Predict
20

0 10

20
Number of Malignant Nodes
K Nearest Neighbors Classification
Neighbor Count (K = 4): 3 1
60

40
Age

Predict
20

0 10

20
Number of Malignant Nodes
What is Needed to Select a KNN
• Correct value for 'K'
Model?
• How to measure closeness of neighbors?
60

40
Age

20

0 10 20
Number of Malignant
Nodes
Measurement of Distance in KNN
60

40
Age

20

0 10

20
Number of Malignant Nodes
Euclidean Distance

Age

Number of Malignant Nodes


ISSUE #01:
Scale is Important for Distance Measuremen

60
24

40 22
Age
20

20
18

1 2 34 5
Number of Surgeries
Scale is Important for Distance
Measurement
"Feature Scaling"
60

40
Age

20

1 2 3 5
4
Number of Surgeries
Scale is Important for Distance
Measurement
"Feature Scaling"
60

40
Nearest
Age
Neighbors!

20

1 2 3 5
4
Number of Surgeries
SOLUTION: Data Normalization

• Between 0 to 1
((x-min(x))/(max(x)-min(x)))

• Between -1 to 1
((x-min(x))/(max(x)-min(x)))*2-1
ISSUE #02: OVERFITTING AND UNDERFITTING
Multiclass decision boundaries break the
data into three or more subsets.

The number of nearest neighbors used for


analysis is also critical.
• Too small a K will give too wiggly a
border.
Example of overfitting or following noise
• Too big K will give too flat a border
• .
Example of underfitting ignoring signal
Let's Predict City and Time of Day

Model Model
Morning Afternoon Evening
Fit

? Model
Is this city Pittsburgh?
What time of day is
Predict it?
(Morning, Afternoon, Evening)
Features and Labels
60
In this case we have:
Two features
• Illumination

Corners
• # corners detected
against background 40

Three labels
• Morning
• Afternoon 20
0 10 20
• Evening Degree of
Illumination
Features and Labels
In this case we have:
60

Two features
• Illumination

Corners
• # corners detected against
background 40

New Example
Three labels known: #illumination, corners
• Morning predict:
morning| afternoon | evening
• Afternoon 20
• Evening 0 10 20
Degree of
Illumination
KNN

Use KNN to make a decision boundary .

If the node falls to the right


• Decision = male (red)

#Pixels in Skin
40
If node falls to the left
• Decision = female (blue)

Hue
Note false positive and negatives. 20
0 10
Predict Node
# Rectangular Shapes
Detected
Regression with KNN

K = 20 K=3 K=1
Characteristics of a KNN Model

• Fast to create model because it simply


stores data
• Slow to predict because many distance
calculations
• Can require lots of memory if data set is
large
K-Nearest Neighbour Example
• Example : Classify whether a customer will respond to a survey question
using a 3-Nearest Neighbor classifier

Customer Age Income No. credit Response


cards
John 35 35K 3 No

Rachel 22 50K 2 Yes

Hannah 63 200K 1 No

Tom 59 170K 1 No

Nellie 25 40K 4 Yes

David 37 50K 2 ?
K-Nearest Neighbour Model
• Example : 3-Nearest
Neighbors
Customer Age
Age Income
Income No. credit
No. credit
cards
cards
Response
Response

John 35
35 35K
35K 3 No

Rachel 22
22 50K
50K 2 Yes

Hannah 63
63 200K
200K 1 No
15.16

Tom 59
59 170K
170K 1 No 15

Nellie 25
25 40K
40K 4 Yes
152.23
David 37 50K 2 ? 15.74 122
37 50K 2 ?
K-Nearest Neighbour Model
• Example : 3-Nearest
Neighbors
Customer Age
Age Income
Income No. credit Response
No. credit
cards
Response cards
John 35
35 35K
35K 3 3 No
No
Rachel 22
22 50K
50K 2 Yes
2
Hannah 63
63 200K
200K 1
Yes No
15.16
59 170K 1 1 No 15
Tom 59 170K
No
25 40K 4 Yes
Nellie 25 40K 152.23
1 122
15.74
37 50K 2
No
2 ?
David 37 50K
Ye?
4
Yes s
Three nearest ones to David are: No, Yes,
Yes
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Classifier Performance
• Decision Trees
• Audio & Speech Recognition
Evaluation Techniques
Training and Tests
Image # Feature 1 Feature 2 Feature 3 Feature 4 Feature 5 Target
1
2
3
4
5 Fold 1
6
7
8
9
10
11
12
13 Fold 2
14
15
16
17
18
19
20
21 Fold 3
22
23
24
Cross-Validation
Folds do not overlap Image # Feature 1 Feature 2 Feature 3 Feature 4 Feature 5 Target
1
2
3
4
Each fold is the same 5 Fold 1
6
7
8
9

size Every example is in a 10


11
12
13 Fold 2
14
15
fold 16
17
18
19
20
21 Fold 3
22
23
24
Cross-Validation
Best fit for Fold 1

Training Test
What about Folds 2 and 3?
Leave One Out Cross-Validation
Removes one datapoint from the
dataset at a time.
Image # Feature 1 Feature 2 Feature 3 Feature 4 Feature 5 Target
1
2
Train from the N-1 datapoints 3
4

• N = number of datapoints 5
6
7
• In this example, N = 24 8
9
10
11
12
13
This is repeated for each 14

datapoint in the set. 15


16
17
18
19

You can also think of the as N- 20


21
fold cross 22

validation 23
24

• That is, 24 datapoints is 24-


folds
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation
Cross Validation

 Leave-one-out cross-validation is extreme


case
False positives – i.e. falsely predicting an event
False negatives – i.e. missing an incoming event

Similarly, we have “true positives” and “true


negatives”

Prediction
0 1

0
TN FP
Truth
1 FN TP
Training and Test Sets
Training set (actual)
• Fit the model

Test set (predicted)


• Measure performance
Predict y with model
Compare with actual y
Measure error
Accuracy Measures

• Accuracy= (TP+TN)/(P+N)
• Sensitivity or true positive rate (TPR)=
TP/(TP+FN) = TP/P
• Specificity or TNR= TN/(FP+TN) = TN/N
• Positive Predictive value (Precision)
(PPV)= Tp/(Tp+Fp)
• Recall = Tp/(Tp+Fn)
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Decision Trees
• Audio & Speech Recognition
Training Examples
Day Outlook Temp. Humidity Wind Play Tennis
D1 Sunny Hot High Weak No
D2 Sunny Hot High Strong No
D3 Overcast Hot High Weak Yes
D4 Rain Mild High Weak Yes
D5 Rain Cool Normal Weak Yes
D6 Rain Cool Normal Strong No
D7 Overcast Cool Normal Weak Yes
D8 Sunny Mild High Weak No
D9 Sunny Cold Normal Weak Yes
D10 Rain Mild Normal Strong Yes
D11 Sunny Mild Normal Strong Yes
D12 Overcast Mild High Strong Yes
D13 Overcast Hot Normal Weak Yes
D14 Rain Mild High Strong No
130
Entropy

• Calculation of entropy
– Entropy(S) = ∑(i=1 to l)-|Si|/|S| * log2(|Si|/|S|)
• S = set of examples
• Si = subset of S with value vi under the target
attribute
• l = size of the range of the target attribute
Entropy: Weather example
Selecting the Next Attribute
S=[9+,5-] S=[9+,5-]
E=0.940 E=0.940
Humidity Wind

High Normal Weak Strong

[3+, 4-] [6+, 1-] [6+, 2-] [3+, 3-]


E=0.985 E=0.592 E=0.811 E=1.0
Gain(S,Humidity) Gain(S,Wind)
=0.940-(7/14)*0.985 =0.940-(8/14)*0.811
– (7/14)*0.592 – (6/14)*1.0
=0.151 =0.048
133
Humidity provides greater info. gain than Wind, w.r.t target classification.
Selecting the Next Attribute
S=[9+,5-]
E=0.940
Outlook

Over
Sunny Rain
cast

[2+, 3-] [4+, 0] [3+, 2-]


E=0.971 E=0.0 E=0.971
Gain(S,Outlook)
=0.940-(5/14)*0.971
-(4/14)*0.0 – (5/14)*0.0971
=0.247
134
Selecting the Next Attribute

The information gain values for the 4 attributes


are:
• Gain(S,Outlook) =0.247
• Gain(S,Humidity) =0.151
• Gain(S,Wind) =0.048
• Gain(S,Temperature) =0.029

where S denotes the collection of training


examples

135
ID3 Algorithm
[D1,D2,…,D14] Outlook
[9+,5-]

Sunny Overcast Rain

Ssunny =[D1,D2,D8,D9,D11] [D3,D7,D12,D13] [D4,D5,D6,D10,D14]


[2+,3-] [4+,0-] [3+,2-]
? Yes ?
Gain(Ssunny, Humidity)=0.970-(3/5)0.0 – 2/5(0.0) = 0.970
Gain(Ssunny, Temp.)=0.970-(2/5)0.0 –2/5(1.0)-(1/5)0.0 = 0.570
Gain(Ssunny, Wind)=0.970= -(2/5)1.0 – 3/5(0.918) = 0.019
136
ID3 Algorithm
Outlook

Sunny Overcast Rain

Humidity Yes Wind


[D3,D7,D12,D13]

High Normal Strong Weak

No Yes No Yes

[D1,D2] [D8,D9,D11] [D6,D14] [D4,D5,D10]


[mistake]
Today’s Lecture

• More Image Feature


Extraction
• Recognition (Classification)
• k-NN Classification
• Decision Trees
• Audio & Speech Recognition
Detection versus Recognition

Detection finds the faces in images Recognition recognizes WHO the


person is
Process of speech recognition

S1

S2
parsing
Speaker Speech
and
Recognition Recognition
arbitration
SK

SN
Process of speech recognition
S1
Switch on
Channel 9

S2
parsing
Speaker Speech
and
Recognition Recognition
arbitration
SK

SN
Process of speech recognition
S1
Who is
speaking?

S2
parsing
Speaker Speech
and
Recognition Recognition
arbitration
SK

Annie SN
David
Cathy

“Authentication”
Process of speech recognition
S1
What is he
saying?

S2
parsing
Speaker Speech
and
Recognition Recognition
arbitration
SK

SN
On,Off,TV
Fridge,Door

“Understanding”
Process of speech recognition
What is he S1
talking
about?

S2
parsing
Speaker Speech
and
Recognition Recognition
arbitration
SK

“Switch”,”to”,”channel”,”nine” SN
Channel->TV
Dim->Lamp
On->TV,Lamp
“Inferring and execution”
Phases of the Project:
 Phase 1: Creating a specific data set (0 - 9).

 Phase 2: Recording the data.

 Phase 3: Feature Extraction.

 Phase 4: Analyzing and evaluating to a specific value/


Training.

 Phase 5: Evaluating the system against the real time data/


Testing.

 Phase 6: Analyzing the identification results.


Phase 1: Creating a specific data set (0 - 9).
 A data set is build containing the numerical words (0-9) of English
language. We had selected to use the numerical words as it would
save our time and it would help us to make extreme feature extraction
of speaker’s voice. Data set for numeric words

Zero (0)
One (1)
Two (2)
Three (3)
Four (4)
Five (5)
Six (6)
Seven (7)
Eight (8)
Nine (9)
References
 Some Slide material has been taken from Dr . M. Usman Akram Computer Vision
Lectures
 CSCI 1430: Introduction to Computer Vision by James Tompkin
 Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
 Pattern Recognition and Analysis Course – A.K. Jain, MSU
 Pattern Classification” by Duda et al., John Wiley & Sons.
 Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002
 Machine Vision: Automated Visual Inspection and Robot Vision”, David Vernon, Prentice Hall, 1991
 www.eu.aibo.com/
 Advances in Human Computer Interaction, Shane Pinder, InTech, Austria, October 2008
 Computer Vision A modern Approach by Frosyth
 http://www.cs.cmu.edu/~16385/s18/
 Introduction to Machine Learning, Alphaydin
 Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
 Pattern Recognition and Analysis Course – A.K. Jain, MSU
 Pattern Classification” by Duda et al., John Wiley & Sons.
 http://www.doc.ic.ac.uk/~sgc/teaching/pre2012/v231/lecture13.html
 Some Material adopted from Dr. Adam Prugel-Bennett Dr. Andrew Ng and Dr. Aman ullah’s Slides

You might also like