SlideShare a Scribd company logo
1 of 11
Download to read offline
Ahsanullah
University of Science
& Technology
Designing a minimum
distance to class mean
classifier
Name : Mufakkharul Islam Nayem
ID : 12.01.04.150
Year & Semester : 4th
2nd
Section : C (C-2)
Assignment 1
Course Title : Pattern Recognition LAB
Course ID : CSE 4214
Date of Submission - December 26, 2015

DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 1
Introduction
“Minimum Distance to Class Mean Classifier” is used to classify unclassified sample
vectors where the vectors clustered in more than one classes are given. For example, in a
dataset containing n sample vectors of dimension d some given sample vectors are already
clustered into classes and some are not. We can classify the unclassified sample vectors with
Class Mean Classifier.
Task
Given the following two-class set of prototypes:
Dataset 1:
w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset1.txt]
w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class1_dataset1.txt]
Dataset 2:
w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset2.txt]
w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class2_dataset2.txt]
Dataset 3:
w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset3.txt]
w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class1_dataset3.txt]
1. Plot all sample points from both classes, but samples from the same class should have the
same color and marker.
2. Using a minimum distance classifier with respect to ‘class mean’, classify the following
points by plotting them with the designated class-color but different marker.
X1 = (5 2)
X2 = (2 -4)
X3 = (-1 8)
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 2
X4 = (-2 -3)
X5 = (-2 -12)
X6 = (-10 6) ; [input file testsample.txt]
Linear Discriminant Function:
!
3. Draw the decision boundary between the two-classes.
Solution
• Plotting two-class set of prototypes
Two classes in each dataset were given. Firstly I plotted all the points. Samples from
the same class were plotted using the same color and marker so that different classes can be
distinguished easily. Here blue stars ‘*’ represent class 1 and red stars ‘*’ represent class 2.
• Calculating the distance from the mean of each class using Linear Discriminant
Function
The mean points of the two classes are calculated & plotted with same class color with
the ‘+’ marker (‘+’ for class 1 & ‘+’ for class 2).
Now for each of the point (X1…X6), I calculated the distance from the mean of each
class using Linear Discriminant Function:
!
Further derivation of the linear discriminant function:
I used the discriminant function in the form, !
so, for the two classes (w1, w2) the function becomes,
!
gi (x) = XT
Yi − 1
2 Yi
T
Yi
gi (x) = XT
Yi − 1
2 Yi
T
Yi
gi (x) = wi
T
x − 1
2 wi
T
wi
g1(x) = w1
T
x − 1
2 w1
T
w1
g2 (x) = w2
T
x − 1
2 w2
T
w2
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 3
The points were assigned to the class with minimum distance from the respected class
mean. I used the same class color but different marker while plotting those points. Here the
circles ‘o’ are the given test samples (‘o’ for class 1 & ‘o’ for class 2).
• Drawing the decision boundary between the two-classes
Decision boundary between the two classes is to be drawn now. For finding out this
boundary I considered all possible points within the range considering those points as over
the boundary line whose distance from both the classes is same. However, I used minimum &
maximum values of x1 to calculate x2 using the following function for the approximate
boundary between the two classes:
!
From this formula I have derived the linear equation to find the decision boundary co-
ordinates for plotting them in the figure. The equation that I derived is,
! ; [here ! ]
Here ‘.-’ line created with orange color (.-.-.-.-) represents the linear decision boundary
between the two classes.
g(x) = g1(x)− g2 (x)
= w1
T
x − 1
2 w1
T
w1 − w2
T
x + 1
2 w2
T
w2
= (w1
T
− w2
T
)x − 1
2 (w1
T
w1 − w2
T
w2 )
(w1
T
− w2
T
)x − 1
2 (w1
T
w1 − w2
T
w2 ) = 0
⇒ COEF1 COEF2( ) x1
x2
⎛
⎝
⎜
⎞
⎠
⎟ + CONSTANT = 0
⇒ COEF1 × x1 + COEF1 × x2 + CONSTANT = 0
⇒ x2 =
COEF1 × x1 + CONSTANT
−COEF2
CONSTANT = − 1
2 (w1
T
w1 − w2
T
w2 )
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 4
Accuracy Discussion
For the 3 datasets figures for each of them is given below,
For dataset 1,
• 2 samples (out of 10) from class 1 & 3 samples (out of 10) from class 2 are misclassified with
respect to decision boundary.
• All the training samples are classified correctly.
• Accuracy is 75%
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 5
For dataset 2,
• 6 samples (out of 20) from class 1 & 8 samples (out of 20) from class 2 are misclassified with
respect to decision boundary.
• All the training samples are classified correctly.
• Accuracy is 65%
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 6
For dataset 3,
• 15 samples (out of 30) from class 1 & 12 samples (out of 30) from class 2 are misclassified
with respect to decision boundary.
• All the training samples are classified correctly.
• Accuracy is 55%
So, from the observation I can say that as sample data increases the classification rate &
accuracy of the decision boundary decreases. But training sample classification is more
accurate.
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 7
Matlab Code
function CMCfinal()
clear
clc
%Given Sample Points
w1=zeros(2,10);
myfile = fopen(‘class1_dataset1.txt','r'); %for dataset2 use
class1_dataset3.txt &
dataset3 use
class1_dataset3.txt
w1 = fscanf(myfile,'%f %f',size(w1));
w1=w1’;
w2=zeros(2,10);
myfile = fopen(‘class2_dataset2.txt','r'); %for dataset2 use
class2_dataset3.txt &
dataset3 use
class2_dataset3.txt
w2 = fscanf(myfile,'%f %f',size(w2));
w2=w2';
%Plotting the Sample Points
figure
title('Minimum Distance to Class Mean Classifier');
hold on
L1=plot(w1(:,1),w1(:,2),'*','MarkerEdgeColor','b');
hold on;
L2=plot(w2(:,1),w2(:,2),'*','MarkerEdgeColor','r');
xlabel('X1');
ylabel('X2');
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 8
%Calculating mean of two classes
y1 = [ mean(w1(:,1)) mean(w1(:,2))];
y2 = [ mean(w2(:,1)) mean(w2(:,2))];
%Plotting mean of two classes
hold on
L3=plot(y1(1),y1(2),'+','MarkerEdgeColor','b');
hold on
L4=plot(y2(1),y2(2),'+','MarkerEdgeColor','r');
%Points for testing
x=zeros(2,6);
myfile = fopen('testsample.txt','r');
x = fscanf(myfile,'%f %f',size(x));
x=x';
% For n number of test samples, calculating Linear Discriminant
Function
for n = 1:length(x)
g1=x(n,:)*y1'-.5*(y1*y1');
g2=x(n,:)*y2’-.5*(y2*y2');
if g1>g2
hold on
L5=plot(x(n,1),x(n,2),'o','MarkerEdgeColor','b');
else
hold on
L6=plot(x(n,1),x(n,2),'o','MarkerEdgeColor','r');
end
end
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 9
% Calculate decision boundary between two classes
minw=min(min(w1(:)),min(w2(:)));
minall=min(minw,min(x(:)));
maxw=max(max(w1(:)),max(w2(:)));
maxall=max(maxw,max(x(:)));
DBx1 = minall:0.1:maxall;
coefficient=(y1-y2);
constant=-0.5*det((y1'*y1-y2'*y2));
for i=1:length(DBx1)
DBx2(i,:) = (coefficient(1,1)*DBx1(:,i)+constant)/
(-coefficient(1,2));
end
%{
for i=1:length(DBx)
DBx2(i,1) = (3*DBx1(1,i)+7.0312)/(1.5);
end
%}
DB = [DBx1' DBx2];
hold on
L7=plot(DB(:,1),DB(:,2),'.-');
legend([L1 L2 L3 L4 L5 L6 L7],{'Class 1','Class 2','Class 1
Mean','Class 2 Mean','Class 1 Test','Class 2
Test','Decision Boundary'},'location','northoutside');
hold off;
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 10
Conclusion
I tried to implement the algorithm in a simple way. No complex calculations were
made. The weakness of the algorithm is its misclassification rate is relatively higher because
the boundary between the two classes is linear.
DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 11

More Related Content

What's hot

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Handwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHandwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHarshana Madusanka Jayamaha
 
Object Detection using Deep Neural Networks
Object Detection using Deep Neural NetworksObject Detection using Deep Neural Networks
Object Detection using Deep Neural NetworksUsman Qayyum
 
Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processingasodariyabhavesh
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extractionRishabh shah
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processingkumari36
 
Deep learning for object detection
Deep learning for object detectionDeep learning for object detection
Deep learning for object detectionWenjing Chen
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & DescriptorsPundrikPatel
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
Fourier descriptors & moments
Fourier descriptors & momentsFourier descriptors & moments
Fourier descriptors & momentsrajisri2
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)Sanjay Saha
 
Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)VARUN KUMAR
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detectionBrodmann17
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentationramya marichamy
 
Chapter 6 color image processing
Chapter 6 color image processingChapter 6 color image processing
Chapter 6 color image processingasodariyabhavesh
 

What's hot (20)

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Line Detection
Line DetectionLine Detection
Line Detection
 
Handwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHandwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural network
 
Object Detection using Deep Neural Networks
Object Detection using Deep Neural NetworksObject Detection using Deep Neural Networks
Object Detection using Deep Neural Networks
 
Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processing
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Yolo
YoloYolo
Yolo
 
Deep learning for object detection
Deep learning for object detectionDeep learning for object detection
Deep learning for object detection
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Image denoising
Image denoising Image denoising
Image denoising
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Image compression .
Image compression .Image compression .
Image compression .
 
Fourier descriptors & moments
Fourier descriptors & momentsFourier descriptors & moments
Fourier descriptors & moments
 
ShortStoryPPT.pptx
ShortStoryPPT.pptxShortStoryPPT.pptx
ShortStoryPPT.pptx
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)
 
Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Chapter 6 color image processing
Chapter 6 color image processingChapter 6 color image processing
Chapter 6 color image processing
 

Viewers also liked

Pattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierPattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierMd Mamunur Rashid
 
Ann chapter-3-single layerperceptron20021031
Ann chapter-3-single layerperceptron20021031Ann chapter-3-single layerperceptron20021031
Ann chapter-3-single layerperceptron20021031frdos
 
Object Recognition: Fourier Descriptors and Minimum-Distance Classification
Object Recognition: Fourier Descriptors and Minimum-Distance ClassificationObject Recognition: Fourier Descriptors and Minimum-Distance Classification
Object Recognition: Fourier Descriptors and Minimum-Distance ClassificationCody Ray
 
International Journal of Image Processing and Pattern Recognition vol 2 issue 1
International Journal of Image Processing and Pattern Recognition vol 2 issue 1International Journal of Image Processing and Pattern Recognition vol 2 issue 1
International Journal of Image Processing and Pattern Recognition vol 2 issue 1JournalsPub www.journalspub.com
 
nural network ER. Abhishek k. upadhyay
nural network ER. Abhishek  k. upadhyaynural network ER. Abhishek  k. upadhyay
nural network ER. Abhishek k. upadhyayabhishek upadhyay
 
Pattern recognition for UX - 13 April 2013
Pattern recognition for UX - 13 April 2013Pattern recognition for UX - 13 April 2013
Pattern recognition for UX - 13 April 2013amelio
 
Fields of digital image processing slides
Fields of digital image processing slidesFields of digital image processing slides
Fields of digital image processing slidesSrinath Dhayalamoorthy
 
Applications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldApplications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldAshwani Srivastava
 
Back propagation
Back propagationBack propagation
Back propagationNagarajan
 
Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Rohit Kumar
 
Biomedical image processing ppt
Biomedical image processing pptBiomedical image processing ppt
Biomedical image processing pptPriyanka Goswami
 

Viewers also liked (15)

Pattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierPattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifier
 
Ann chapter-3-single layerperceptron20021031
Ann chapter-3-single layerperceptron20021031Ann chapter-3-single layerperceptron20021031
Ann chapter-3-single layerperceptron20021031
 
Object Recognition: Fourier Descriptors and Minimum-Distance Classification
Object Recognition: Fourier Descriptors and Minimum-Distance ClassificationObject Recognition: Fourier Descriptors and Minimum-Distance Classification
Object Recognition: Fourier Descriptors and Minimum-Distance Classification
 
International Journal of Image Processing and Pattern Recognition vol 2 issue 1
International Journal of Image Processing and Pattern Recognition vol 2 issue 1International Journal of Image Processing and Pattern Recognition vol 2 issue 1
International Journal of Image Processing and Pattern Recognition vol 2 issue 1
 
nural network ER. Abhishek k. upadhyay
nural network ER. Abhishek  k. upadhyaynural network ER. Abhishek  k. upadhyay
nural network ER. Abhishek k. upadhyay
 
Application of image processing
Application of image processingApplication of image processing
Application of image processing
 
Pattern recognition for UX - 13 April 2013
Pattern recognition for UX - 13 April 2013Pattern recognition for UX - 13 April 2013
Pattern recognition for UX - 13 April 2013
 
CSC446: Pattern Recognition (LN8)
CSC446: Pattern Recognition (LN8)CSC446: Pattern Recognition (LN8)
CSC446: Pattern Recognition (LN8)
 
Fields of digital image processing slides
Fields of digital image processing slidesFields of digital image processing slides
Fields of digital image processing slides
 
Applications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldApplications of Digital image processing in Medical Field
Applications of Digital image processing in Medical Field
 
Back propagation
Back propagationBack propagation
Back propagation
 
Pattern Recognition
Pattern RecognitionPattern Recognition
Pattern Recognition
 
Introduction to pattern recognition
Introduction to pattern recognitionIntroduction to pattern recognition
Introduction to pattern recognition
 
Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.
 
Biomedical image processing ppt
Biomedical image processing pptBiomedical image processing ppt
Biomedical image processing ppt
 

Similar to Pattern Recognition - Designing a minimum distance class mean classifier

Implementing Minimum Error Rate Classifier
Implementing Minimum Error Rate ClassifierImplementing Minimum Error Rate Classifier
Implementing Minimum Error Rate ClassifierDipesh Shome
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning VMax Kleiner
 
Implementation of K-Nearest Neighbor Algorithm
Implementation of K-Nearest Neighbor AlgorithmImplementation of K-Nearest Neighbor Algorithm
Implementation of K-Nearest Neighbor AlgorithmDipesh Shome
 
CLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxCLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxShwetapadmaBabu1
 
Lecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptLecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptSyedNahin1
 
Application of combined support vector machines in process fault diagnosis
Application of combined support vector machines in process fault diagnosisApplication of combined support vector machines in process fault diagnosis
Application of combined support vector machines in process fault diagnosisDr.Pooja Jain
 
Soạn thảo văn bản bằng LATEX
Soạn thảo văn bản bằng LATEXSoạn thảo văn bản bằng LATEX
Soạn thảo văn bản bằng LATEXHuỳnh Lâm
 
CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...Raed Aldahdooh
 
Lecture on linerar discriminatory analysis
Lecture on linerar discriminatory analysisLecture on linerar discriminatory analysis
Lecture on linerar discriminatory analysisdevcb13d
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationMarjan Sterjev
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAminaRepo
 
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...CSCJournals
 
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...Waqas Tariq
 

Similar to Pattern Recognition - Designing a minimum distance class mean classifier (20)

Lda
LdaLda
Lda
 
Implementing Minimum Error Rate Classifier
Implementing Minimum Error Rate ClassifierImplementing Minimum Error Rate Classifier
Implementing Minimum Error Rate Classifier
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
 
Implementation of K-Nearest Neighbor Algorithm
Implementation of K-Nearest Neighbor AlgorithmImplementation of K-Nearest Neighbor Algorithm
Implementation of K-Nearest Neighbor Algorithm
 
CLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptxCLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptx
 
Lecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptLecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.ppt
 
Application of combined support vector machines in process fault diagnosis
Application of combined support vector machines in process fault diagnosisApplication of combined support vector machines in process fault diagnosis
Application of combined support vector machines in process fault diagnosis
 
Mod mean quartile
Mod mean quartileMod mean quartile
Mod mean quartile
 
Soạn thảo văn bản bằng LATEX
Soạn thảo văn bản bằng LATEXSoạn thảo văn bản bằng LATEX
Soạn thảo văn bản bằng LATEX
 
CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
 
Feature Selection
Feature Selection Feature Selection
Feature Selection
 
Lecture on linerar discriminatory analysis
Lecture on linerar discriminatory analysisLecture on linerar discriminatory analysis
Lecture on linerar discriminatory analysis
 
K mean-clustering
K mean-clusteringK mean-clustering
K mean-clustering
 
Practice test1 solution
Practice test1 solutionPractice test1 solution
Practice test1 solution
 
ICPR 2016
ICPR 2016ICPR 2016
ICPR 2016
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and Visualization
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
 
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
 
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
The Positive Effects of Fuzzy C-Means Clustering on Supervised Learning Class...
 

Recently uploaded

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 

Recently uploaded (20)

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 

Pattern Recognition - Designing a minimum distance class mean classifier

  • 1. Ahsanullah University of Science & Technology Designing a minimum distance to class mean classifier Name : Mufakkharul Islam Nayem ID : 12.01.04.150 Year & Semester : 4th 2nd Section : C (C-2) Assignment 1 Course Title : Pattern Recognition LAB Course ID : CSE 4214 Date of Submission - December 26, 2015
 DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 1
  • 2. Introduction “Minimum Distance to Class Mean Classifier” is used to classify unclassified sample vectors where the vectors clustered in more than one classes are given. For example, in a dataset containing n sample vectors of dimension d some given sample vectors are already clustered into classes and some are not. We can classify the unclassified sample vectors with Class Mean Classifier. Task Given the following two-class set of prototypes: Dataset 1: w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset1.txt] w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class1_dataset1.txt] Dataset 2: w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset2.txt] w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class2_dataset2.txt] Dataset 3: w1 = {(2 -1),(3 0),(3 2),(-1-3),(4 1),(-2 -4),(0 -1),(-2 2),(-1 -4),(-4 1)} [input file class1_dataset3.txt] w2 = {(0 0),(-2 1),(-1 -1),(-4 4),(-4 1),(2 6),(2 2),(3 1),(3 -1),(-1 -3)} [input file class1_dataset3.txt] 1. Plot all sample points from both classes, but samples from the same class should have the same color and marker. 2. Using a minimum distance classifier with respect to ‘class mean’, classify the following points by plotting them with the designated class-color but different marker. X1 = (5 2) X2 = (2 -4) X3 = (-1 8) DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 2
  • 3. X4 = (-2 -3) X5 = (-2 -12) X6 = (-10 6) ; [input file testsample.txt] Linear Discriminant Function: ! 3. Draw the decision boundary between the two-classes. Solution • Plotting two-class set of prototypes Two classes in each dataset were given. Firstly I plotted all the points. Samples from the same class were plotted using the same color and marker so that different classes can be distinguished easily. Here blue stars ‘*’ represent class 1 and red stars ‘*’ represent class 2. • Calculating the distance from the mean of each class using Linear Discriminant Function The mean points of the two classes are calculated & plotted with same class color with the ‘+’ marker (‘+’ for class 1 & ‘+’ for class 2). Now for each of the point (X1…X6), I calculated the distance from the mean of each class using Linear Discriminant Function: ! Further derivation of the linear discriminant function: I used the discriminant function in the form, ! so, for the two classes (w1, w2) the function becomes, ! gi (x) = XT Yi − 1 2 Yi T Yi gi (x) = XT Yi − 1 2 Yi T Yi gi (x) = wi T x − 1 2 wi T wi g1(x) = w1 T x − 1 2 w1 T w1 g2 (x) = w2 T x − 1 2 w2 T w2 DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 3
  • 4. The points were assigned to the class with minimum distance from the respected class mean. I used the same class color but different marker while plotting those points. Here the circles ‘o’ are the given test samples (‘o’ for class 1 & ‘o’ for class 2). • Drawing the decision boundary between the two-classes Decision boundary between the two classes is to be drawn now. For finding out this boundary I considered all possible points within the range considering those points as over the boundary line whose distance from both the classes is same. However, I used minimum & maximum values of x1 to calculate x2 using the following function for the approximate boundary between the two classes: ! From this formula I have derived the linear equation to find the decision boundary co- ordinates for plotting them in the figure. The equation that I derived is, ! ; [here ! ] Here ‘.-’ line created with orange color (.-.-.-.-) represents the linear decision boundary between the two classes. g(x) = g1(x)− g2 (x) = w1 T x − 1 2 w1 T w1 − w2 T x + 1 2 w2 T w2 = (w1 T − w2 T )x − 1 2 (w1 T w1 − w2 T w2 ) (w1 T − w2 T )x − 1 2 (w1 T w1 − w2 T w2 ) = 0 ⇒ COEF1 COEF2( ) x1 x2 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ + CONSTANT = 0 ⇒ COEF1 × x1 + COEF1 × x2 + CONSTANT = 0 ⇒ x2 = COEF1 × x1 + CONSTANT −COEF2 CONSTANT = − 1 2 (w1 T w1 − w2 T w2 ) DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 4
  • 5. Accuracy Discussion For the 3 datasets figures for each of them is given below, For dataset 1, • 2 samples (out of 10) from class 1 & 3 samples (out of 10) from class 2 are misclassified with respect to decision boundary. • All the training samples are classified correctly. • Accuracy is 75% DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 5
  • 6. For dataset 2, • 6 samples (out of 20) from class 1 & 8 samples (out of 20) from class 2 are misclassified with respect to decision boundary. • All the training samples are classified correctly. • Accuracy is 65% DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 6
  • 7. For dataset 3, • 15 samples (out of 30) from class 1 & 12 samples (out of 30) from class 2 are misclassified with respect to decision boundary. • All the training samples are classified correctly. • Accuracy is 55% So, from the observation I can say that as sample data increases the classification rate & accuracy of the decision boundary decreases. But training sample classification is more accurate. DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 7
  • 8. Matlab Code function CMCfinal() clear clc %Given Sample Points w1=zeros(2,10); myfile = fopen(‘class1_dataset1.txt','r'); %for dataset2 use class1_dataset3.txt & dataset3 use class1_dataset3.txt w1 = fscanf(myfile,'%f %f',size(w1)); w1=w1’; w2=zeros(2,10); myfile = fopen(‘class2_dataset2.txt','r'); %for dataset2 use class2_dataset3.txt & dataset3 use class2_dataset3.txt w2 = fscanf(myfile,'%f %f',size(w2)); w2=w2'; %Plotting the Sample Points figure title('Minimum Distance to Class Mean Classifier'); hold on L1=plot(w1(:,1),w1(:,2),'*','MarkerEdgeColor','b'); hold on; L2=plot(w2(:,1),w2(:,2),'*','MarkerEdgeColor','r'); xlabel('X1'); ylabel('X2'); DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 8
  • 9. %Calculating mean of two classes y1 = [ mean(w1(:,1)) mean(w1(:,2))]; y2 = [ mean(w2(:,1)) mean(w2(:,2))]; %Plotting mean of two classes hold on L3=plot(y1(1),y1(2),'+','MarkerEdgeColor','b'); hold on L4=plot(y2(1),y2(2),'+','MarkerEdgeColor','r'); %Points for testing x=zeros(2,6); myfile = fopen('testsample.txt','r'); x = fscanf(myfile,'%f %f',size(x)); x=x'; % For n number of test samples, calculating Linear Discriminant Function for n = 1:length(x) g1=x(n,:)*y1'-.5*(y1*y1'); g2=x(n,:)*y2’-.5*(y2*y2'); if g1>g2 hold on L5=plot(x(n,1),x(n,2),'o','MarkerEdgeColor','b'); else hold on L6=plot(x(n,1),x(n,2),'o','MarkerEdgeColor','r'); end end DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 9
  • 10. % Calculate decision boundary between two classes minw=min(min(w1(:)),min(w2(:))); minall=min(minw,min(x(:))); maxw=max(max(w1(:)),max(w2(:))); maxall=max(maxw,max(x(:))); DBx1 = minall:0.1:maxall; coefficient=(y1-y2); constant=-0.5*det((y1'*y1-y2'*y2)); for i=1:length(DBx1) DBx2(i,:) = (coefficient(1,1)*DBx1(:,i)+constant)/ (-coefficient(1,2)); end %{ for i=1:length(DBx) DBx2(i,1) = (3*DBx1(1,i)+7.0312)/(1.5); end %} DB = [DBx1' DBx2]; hold on L7=plot(DB(:,1),DB(:,2),'.-'); legend([L1 L2 L3 L4 L5 L6 L7],{'Class 1','Class 2','Class 1 Mean','Class 2 Mean','Class 1 Test','Class 2 Test','Decision Boundary'},'location','northoutside'); hold off; DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 10
  • 11. Conclusion I tried to implement the algorithm in a simple way. No complex calculations were made. The weakness of the algorithm is its misclassification rate is relatively higher because the boundary between the two classes is linear. DESIGNING A MINIMUM DISTANCE TO CLASS MEAN CLASSIFIER 11