Class12-PatternClassification_PerformanceMetric_ReferenceTemplate
Class12-PatternClassification_PerformanceMetric_ReferenceTemplate
Classification
Confusion Matrix – 2-class
Total test
samples
in class1
3
Confusion Matrix – 2-class
Total test
samples
in class2
4
Confusion Matrix – 2-class
Total test
samples
predicted as
class1
Total test
samples
predicted as
class2
7
Confusion Matrix - Multiclass
Illustration: Number of classes is 3. It can be extended to any
number of classes
13
Binary (2-class) Classification:
Precision, Recall and F-measure
• Precision:
– Number of samples correctly classified as positive class,
out of all the examples classified as positive class
– It is also called positive predictive value
Binary (2-class) Classification:
Precision, Recall and F-measure
• Recall:
– Number of samples correctly classified as positive class,
out of all the examples belonging to positive class
– It is also called as sensitivity or true positive rate (TPR)
15
Binary (2-class) Classification:
Precision, Recall and F-measure
16
Supervised Machine Learning:
Pattern Classification
K-Nearest Neighbor, Reference Template Method
K-Nearest Neighbours (K-NN) Method
• Consider the class labels of the K training examples
nearest to the test example
• Step 1: Compute Euclidean distance for a test
example x with every training examples, x1, x2, …, xn,
…, xN • Step 2: Sort the examples in
the training set in the
ascending order of the
distance to x
x2 • Step 3: Choose the first K
examples in the sorted list
– K is the number of
neighbours for text
x1 example
• Step 4: Test example is assigned the most common
class among its K neighbours
18
Reference Templates Method
19
Reference Templates Method
• Each class is represented by its reference templates
– Mean of each data points of each class as reference template
• For a test example, compute an Euclidean distance to all the
reference template corresponding to each class, ED(x, μi)
x2
• Learning: Estimating first
order statistics (mean)
from the data of each
class
x1 21
Illustration of Reference Templates
Method: Adult(1)-Child(0) Classification
• Training Phase:
– Compute sample mean vector from training
data of class 0 (Child)
μ0= [103.60 30.66]
22
Illustration of Reference Templates
Method: Adult(1)-Child(0) Classification
• Training Phase:
– Compute sample mean vector from training
data of class 0 (Child)
μ0= [103.60 30.66]
23
Illustration of Reference Templates Method:
Adult(1)-Child(0) Classification
• Test Phase - Classification:
Test Example, x:
Height Weight Class
μ0 103.60 30.66 0
μ1 166.60 67.12 1
Weight
in Kg
Height in cm
σjk: Covariance of
jth and kth attribute
25
Modified Reference Templates Method
• Each class is represented by one or more reference templates
– Mean and variance (covariance) of data points of each class as
reference template
• For a test example, compute a Mahalanobis distance to all
the reference template corresponding to each class, MD(x, μi, Σi)
x2
x1 28
Illustration of Reference Templates Method:
Adult(1)-Child(0) Classification
• Training Phase:
– Compute sample mean vector from training
data of class 0 (Child)
μ0= [103.60 30.66]
– Compute sample covariance matrix from
training data of class 0 (Child)
29
Illustration of Reference Templates Method:
Adult(1)-Child(0) Classification
• Training Phase:
– Compute sample mean vector from training
data of class 0 (Child)
μ0= [103.60 30.66]
– Compute sample covariance matrix from
training data of class 0 (Child)
Weight
μ1= [166.00 67.12] in Kg
Class
1
Σ1= 110.67 160.53
160.53 255.49
Height in cm
• Compute Mahalanobis distance of test sample,
x with mean vector and covariance matrix of
class 0 (Child): MD(x, μ0, Σ0) = 4.87 Class label of x =
• Compute Mahalanobis distance of test sample, Adult
x with mean vector and covariance matrix of
class 1 (Adult): MD(x, μ2, Σ2) = 2.07 31
Classification using Reference
Template Methods
• For a test example, a distance measure is computed with
the reference template of each class
• The class of the reference template with least distance is
assigned to the test pattern
• When Mahalanobis distance is used, it gives the notion
that distance measure is computed between a test
example and the distribution (density) of a class
– Distribution (density) of class: All the training examples are
drawn from that distribution
– Density here is normal (Gaussian) density
• In other way, we are interested to estimate probability of
class, P(Ci | x)
– Given the test example x, what is the probability that it
belongs to ith class (Ci)
• Solution: Bayes classifier
32
Text Books
33