SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Image segmentation with deep learning
Image segmentation with deep learningImage segmentation with deep learning
Image segmentation with deep learningAntonio Rueda-Toicen
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIPbabak danyal
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processingAbinaya B
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainMadhu Bala
 
Sharpening using frequency Domain Filter
Sharpening using frequency Domain FilterSharpening using frequency Domain Filter
Sharpening using frequency Domain Filterarulraj121
 
Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)VARUN KUMAR
 
Thresholding.ppt
Thresholding.pptThresholding.ppt
Thresholding.pptshankar64
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentationramya marichamy
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation modelAnupriyaDurai
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersKarthika Ramachandran
 
Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Rohit Kumar
 

La actualidad más candente (20)

Image segmentation with deep learning
Image segmentation with deep learningImage segmentation with deep learning
Image segmentation with deep learning
 
Morphological operations
Morphological operationsMorphological operations
Morphological operations
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIP
 
Histogram Equalization
Histogram EqualizationHistogram Equalization
Histogram Equalization
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Hit and-miss transform
Hit and-miss transformHit and-miss transform
Hit and-miss transform
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processing
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial Domain
 
Sharpening using frequency Domain Filter
Sharpening using frequency Domain FilterSharpening using frequency Domain Filter
Sharpening using frequency Domain Filter
 
Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)
 
image enhancement
 image enhancement image enhancement
image enhancement
 
Thresholding.ppt
Thresholding.pptThresholding.ppt
Thresholding.ppt
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation model
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.
 

Destacado

Pattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierPattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierMd Mamunur Rashid
 
Designing A Minimum Distance to Class Mean Classifier
Designing A Minimum Distance to Class Mean ClassifierDesigning A Minimum Distance to Class Mean Classifier
Designing A Minimum Distance to Class Mean ClassifierMd. Toufique Hasan
 
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
 
Biomedical image processing ppt
Biomedical image processing pptBiomedical image processing ppt
Biomedical image processing pptPriyanka Goswami
 

Destacado (15)

Pattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierPattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifier
 
Designing A Minimum Distance to Class Mean Classifier
Designing A Minimum Distance to Class Mean ClassifierDesigning A Minimum Distance to Class Mean Classifier
Designing A Minimum Distance to 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
 
Biomedical image processing ppt
Biomedical image processing pptBiomedical image processing ppt
Biomedical image processing ppt
 

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

Designing a Minimum Distance classifier to Class Mean Classifier
Designing a Minimum Distance classifier to Class Mean ClassifierDesigning a Minimum Distance classifier to Class Mean Classifier
Designing a Minimum Distance classifier to Class Mean ClassifierDipesh Shome
 
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
 

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

Designing a Minimum Distance classifier to Class Mean Classifier
Designing a Minimum Distance classifier to Class Mean ClassifierDesigning a Minimum Distance classifier to Class Mean Classifier
Designing a Minimum Distance classifier to Class Mean Classifier
 
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...
 

Último

COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
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
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
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
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Último (20)

COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
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
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
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
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 

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