SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
Ahsanullah University of Science and Technology
Department of Computer Science and Engineering
Experiment No 1
Designing A Minimum Distance to Class
Mean Classifier
Pattern Recognition Lab
CSE – 4214
Submitted By
Name: Md. Toufique Hasan
ID: 12.02.04.069
Year: 4th
Semester: 2nd
Section: B (B1)
Date of Submission: 18-06-2016
Designing A Minimum Distance to Class Mean Classifier
Md. Toufique Hasan
Department of Computer Science and Engineering
Ahsanullah University of Science and Technology
Dhaka, Bangladesh
toufique.hasan@hotmail.com
Objective
The main objective of this assignment is to design a
minimum distance to class mean classifier
1. Introduction
Class Mean Classifier is used to classify unclassified
sample vectors where the vectors are classified in more
than one class. For example, in our dataset we have some
sample vectors. Some given sample vectors are already
classified into different classes and some are not
classified. We can classify the unclassified sample
vectors by the help of Minimum Distance to Class Mean
Classifier.
2. Task
Given the following two-class set of prototypes
w1 = {(2,2), (3,1), (3,3), (-1,-3), (4,2), (-2,-2)}
w2 = {(0,0), (-2,2), (-1,-1), (-4,2), (-4,3), (2,6)}
a. Plot all sample points from both classes, but
samples from the same class should have the
same color and marker.
b. 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 = (-1, -1)
X2 = (3, 2)
X3 = (-2, 1)
X4 = (8, 2)
Linear Discriminant Function:
c. Draw the decision boundary between the two-
classes.
3. Implementation
a. First Step (Plot all sample points):
Two classes are given. At first we have to plot
all the sample points of both classes. Samples from the
same class are plotted using the same color and marker.
So that different classes can be distinguished easily. Here
red stars ‘*’ represent class w1 and green stars ‘*’
represent class w2.
Figure 1: Plot all the sample points
b. Second Step (Classify the following points):
The mean points of the two classes are
calculated & plotted with same class color with the ‘O’
marker (‘O’ for class w1 & ‘O’ for class w2).
Now for each of the point (X1, X2, X3, X4) we can
calculate the distance from the calculate mean of each
class using Linear Discriminant Function.
Here red cross ‘x’ represent class w1 and green cross ‘x’
represent class w2. We use the same class color but
different marker while plotting those points.
Figure 2: Minimum distance classifier with respect to
class mean & classify some samples
c. Third Step (Drawing the decision boundary)
In the last step, we will draw the decision boundary.
For finding out the decision boundary we will consider
all possible points within the range. We will consider
those points as over the boundary line whose distance
from both the classes are same. Here ‘-.’ line creates with
blue color represents the linear decision boundary
between the two classes.
Figure 3: Drawing the decision boundary
4. MATLAB Code
%Import Sample Points From Text
Files
w1 = zeros(2,10);
myfile = fopen('w1.txt','r');
w1 = fscanf(myfile,'%f
%f',size(w1));
w1 = w1';
w2 = zeros(2,10);
myfile = fopen('w2.txt','r');
w2 = fscanf(myfile,'%f
%f',size(w2));
w2 = w2';
%Plotting The Sample Points
title('Designing a Minimum
Distance to Class Mean
Classifier','FontName','Comic Sans
MS');
hold on;
p1 =
plot(w1(:,1),w1(:,2),'h','MarkerEd
geColor','r','LineWidth',1.5);
hold on;
p2 =
plot(w2(:,1),w2(:,2),'h','MarkerEd
geColor','g','LineWidth',1.5);
xlabel('X1');
ylabel('X2');
%Calculating Class Mean
y1 = [mean(w1(:,1)),mean(w1(:,2))]
y2 = [mean(w2(:,1)),mean(w2(:,2))]
%Plotting Class Mean
hold on
p3 =
plot(y1(1),y1(2),'o','MarkerEdgeCo
lor','r','LineWidth',1.5);
hold on
p4 =
plot(y2(1),y2(2),'o','MarkerEdgeCo
lor','g','LineWidth',1.5);
%Points for testing
sample = zeros(2,10);
myfile = fopen('sample.txt','r');
sample = fscanf(myfile,'%f
%f',size(sample));
sample = sample';
5. Result Analysis
We have taken two datasets for result analysis. Each
classes in datasets contains 10 sample values. Some of
them are classified and some are not.
For dataset 1, 4 samples out of 10 from class 1 are
misclassified with respect to decision boundary. And all
the training samples are classified correctly. So, the
accuracy is 80%.
Figure 4: Result analysis for dataset 1
Now for dataset 2, 2 samples out of 10 from class 1
and 3 samples out of 10 from class 2 are miss classified
with respect to decision boundary. And all the training
samples are classified correctly. So, the accuracy is 75%.
Figure 5: Result analysis for dataset 2
%Calculating Linear Discriminant
Function
for i = 1:length(sample)
g1 = sample(i,:)*y1'-
.5*(y1*y1');
g2 = sample(i,:)*y2'-
.5*(y2*y2');
if g1 > g2
plot(sample(i,1),sample(i,2),'x','
MarkerEdgeColor','r','LineWidth',1
.5);
else
plot(sample(i,1),sample(i,2),'x','
MarkerEdgeColor','g','LineWidth',1
.5);
end
end
%Decision Boundary Between Two-
classes
coefficient = y1-y2;
constant = -0.5*det((y1' * y1)-
(y2' * y2));
b = [-4:2:8];
for i = 1:length(b)
y(:,i) = -((coefficient(1,1)*
b(:,i)+constant)/coefficient(1,2))
;
end
d_boundary = [b',y'];
plot(d_boundary(:,1),d_boundary(:,
2),'-.b');
hold off;
6. Conclusion
In this assignment some sample are classified and
some are misclassified. I want to apply this assignment in
an easy away. It has simple calculation. So that the speed
of this result is too efficient. The main weakness of this
algorithm is its misclassification rate is higher because
the boundary between two classes is linear.

Más contenido relacionado

La actualidad más candente

matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesRakesh kumar jha
 
3F3 – Digital Signal Processing (DSP) - Part1
3F3 – Digital Signal Processing (DSP) - Part13F3 – Digital Signal Processing (DSP) - Part1
3F3 – Digital Signal Processing (DSP) - Part1op205
 
Signals and Systems 1.pptx
Signals and Systems 1.pptxSignals and Systems 1.pptx
Signals and Systems 1.pptxAhmedAli898175
 
Radar signal processing
Radar signal processingRadar signal processing
Radar signal processingMustahid Ali
 
Chapter1 - Signal and System
Chapter1 - Signal and SystemChapter1 - Signal and System
Chapter1 - Signal and SystemAttaporn Ninsuwan
 
EC8394- ANALOG AND DIGITAL COMMUNICATION unit II
EC8394- ANALOG AND DIGITAL COMMUNICATION  unit IIEC8394- ANALOG AND DIGITAL COMMUNICATION  unit II
EC8394- ANALOG AND DIGITAL COMMUNICATION unit IIManojKumar791621
 
Dsp U Lec05 The Z Transform
Dsp U   Lec05 The Z TransformDsp U   Lec05 The Z Transform
Dsp U Lec05 The Z Transformtaha25
 
Digital signal processing computer based approach - sanjit k. mitra (2nd ed)
Digital signal processing   computer based approach - sanjit k. mitra (2nd ed)Digital signal processing   computer based approach - sanjit k. mitra (2nd ed)
Digital signal processing computer based approach - sanjit k. mitra (2nd ed)Surbhi Maheshwari
 
signal to quantization noise ratio sqnr | Communication Systems
signal to quantization noise ratio sqnr | Communication Systemssignal to quantization noise ratio sqnr | Communication Systems
signal to quantization noise ratio sqnr | Communication SystemsLearn By Watch
 
Computing DFT using Matrix method
Computing DFT using Matrix methodComputing DFT using Matrix method
Computing DFT using Matrix methodSarang Joshi
 
Design System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential CircuitsDesign System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential CircuitsIndira Priyadarshini
 
multirate signal processing for speech
multirate signal processing for speechmultirate signal processing for speech
multirate signal processing for speechRudra Prasad Maiti
 
Signal Processing Lab Report
Signal Processing Lab ReportSignal Processing Lab Report
Signal Processing Lab ReportTyler Mooney
 
Discrete Fourier Transform
Discrete Fourier TransformDiscrete Fourier Transform
Discrete Fourier TransformAbhishek Choksi
 

La actualidad más candente (20)

matlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequencesmatlab code of shifting and folding of two sequences
matlab code of shifting and folding of two sequences
 
Multirate DSP
Multirate DSPMultirate DSP
Multirate DSP
 
3F3 – Digital Signal Processing (DSP) - Part1
3F3 – Digital Signal Processing (DSP) - Part13F3 – Digital Signal Processing (DSP) - Part1
3F3 – Digital Signal Processing (DSP) - Part1
 
Lti system
Lti systemLti system
Lti system
 
Signals and Systems 1.pptx
Signals and Systems 1.pptxSignals and Systems 1.pptx
Signals and Systems 1.pptx
 
DFT and IDFT Matlab Code
DFT and IDFT Matlab CodeDFT and IDFT Matlab Code
DFT and IDFT Matlab Code
 
Radar signal processing
Radar signal processingRadar signal processing
Radar signal processing
 
Digital Filters Part 1
Digital Filters Part 1Digital Filters Part 1
Digital Filters Part 1
 
Lecture123
Lecture123Lecture123
Lecture123
 
Chapter1 - Signal and System
Chapter1 - Signal and SystemChapter1 - Signal and System
Chapter1 - Signal and System
 
EC8394- ANALOG AND DIGITAL COMMUNICATION unit II
EC8394- ANALOG AND DIGITAL COMMUNICATION  unit IIEC8394- ANALOG AND DIGITAL COMMUNICATION  unit II
EC8394- ANALOG AND DIGITAL COMMUNICATION unit II
 
Dsp U Lec05 The Z Transform
Dsp U   Lec05 The Z TransformDsp U   Lec05 The Z Transform
Dsp U Lec05 The Z Transform
 
Digital signal processing computer based approach - sanjit k. mitra (2nd ed)
Digital signal processing   computer based approach - sanjit k. mitra (2nd ed)Digital signal processing   computer based approach - sanjit k. mitra (2nd ed)
Digital signal processing computer based approach - sanjit k. mitra (2nd ed)
 
signal to quantization noise ratio sqnr | Communication Systems
signal to quantization noise ratio sqnr | Communication Systemssignal to quantization noise ratio sqnr | Communication Systems
signal to quantization noise ratio sqnr | Communication Systems
 
Computing DFT using Matrix method
Computing DFT using Matrix methodComputing DFT using Matrix method
Computing DFT using Matrix method
 
Design System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential CircuitsDesign System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential Circuits
 
multirate signal processing for speech
multirate signal processing for speechmultirate signal processing for speech
multirate signal processing for speech
 
Signal Processing Lab Report
Signal Processing Lab ReportSignal Processing Lab Report
Signal Processing Lab Report
 
Introduction to dsp
Introduction to dspIntroduction to dsp
Introduction to dsp
 
Discrete Fourier Transform
Discrete Fourier TransformDiscrete Fourier Transform
Discrete Fourier Transform
 

Similar a Designing A Minimum Distance to Class Mean Classifier

Pattern Recognition - Designing a minimum distance class mean classifier
Pattern Recognition - Designing a minimum distance class mean classifierPattern Recognition - Designing a minimum distance class mean classifier
Pattern Recognition - Designing a minimum distance class mean classifierNayem Nayem
 
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 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
 
Clustering-dendogram.pptx
Clustering-dendogram.pptxClustering-dendogram.pptx
Clustering-dendogram.pptxANKIT915111
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationMarjan Sterjev
 
Distance and midpoint formula
Distance and midpoint formulaDistance and midpoint formula
Distance and midpoint formulaNoel Guzman
 
Unit-1 Introduction and Mathematical Preliminaries.pptx
Unit-1 Introduction and Mathematical Preliminaries.pptxUnit-1 Introduction and Mathematical Preliminaries.pptx
Unit-1 Introduction and Mathematical Preliminaries.pptxavinashBajpayee1
 
Cluster Analysis: Measuring Similarity & Dissimilarity
Cluster Analysis: Measuring Similarity & DissimilarityCluster Analysis: Measuring Similarity & Dissimilarity
Cluster Analysis: Measuring Similarity & DissimilarityShivarkarSandip
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfRajJain516913
 
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...ArchiLab 7
 
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...sipij
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 

Similar a Designing A Minimum Distance to Class Mean Classifier (20)

Pattern Recognition - Designing a minimum distance class mean classifier
Pattern Recognition - Designing a minimum distance class mean classifierPattern Recognition - Designing a minimum distance class mean classifier
Pattern Recognition - Designing a minimum distance class mean classifier
 
Pattern Recognition: Class mean classifier
Pattern Recognition: Class mean classifierPattern Recognition: Class mean classifier
Pattern Recognition: 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 Classifier
 
Lda
LdaLda
Lda
 
Km2417821785
Km2417821785Km2417821785
Km2417821785
 
[PPT]
[PPT][PPT]
[PPT]
 
Implementing Minimum Error Rate Classifier
Implementing Minimum Error Rate ClassifierImplementing Minimum Error Rate Classifier
Implementing Minimum Error Rate Classifier
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Clustering-dendogram.pptx
Clustering-dendogram.pptxClustering-dendogram.pptx
Clustering-dendogram.pptx
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and Visualization
 
Lect4
Lect4Lect4
Lect4
 
Distance and midpoint formula
Distance and midpoint formulaDistance and midpoint formula
Distance and midpoint formula
 
Unit-1 Introduction and Mathematical Preliminaries.pptx
Unit-1 Introduction and Mathematical Preliminaries.pptxUnit-1 Introduction and Mathematical Preliminaries.pptx
Unit-1 Introduction and Mathematical Preliminaries.pptx
 
Cluster Analysis: Measuring Similarity & Dissimilarity
Cluster Analysis: Measuring Similarity & DissimilarityCluster Analysis: Measuring Similarity & Dissimilarity
Cluster Analysis: Measuring Similarity & Dissimilarity
 
test & measuement
test & measuementtest & measuement
test & measuement
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...
Fessant aknin oukhellou_midenet_2001:comparison_of_supervised_self_organizing...
 
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...
Introducing New Parameters to Compare the Accuracy and Reliability of Mean-Sh...
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 

Último

Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...drjose256
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualBalamuruganV28
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesRashidFaridChishti
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Nitin Sonavane
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
 
Quiz application system project report..pdf
Quiz application system project report..pdfQuiz application system project report..pdf
Quiz application system project report..pdfKamal Acharya
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
Online book store management system project.pdf
Online book store management system project.pdfOnline book store management system project.pdf
Online book store management system project.pdfKamal Acharya
 
Introduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of ArduinoIntroduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of ArduinoAbhimanyu Sangale
 
Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemSampad Kar
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1T.D. Shashikala
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfJNTUA
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfragupathi90
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)NareenAsad
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfAshrafRagab14
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.MdManikurRahman
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineLow rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineAftabkhan575376
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfJNTUA
 
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...jiyav969
 

Último (20)

Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Quiz application system project report..pdf
Quiz application system project report..pdfQuiz application system project report..pdf
Quiz application system project report..pdf
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Online book store management system project.pdf
Online book store management system project.pdfOnline book store management system project.pdf
Online book store management system project.pdf
 
Introduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of ArduinoIntroduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of Arduino
 
Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineLow rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
 

Designing A Minimum Distance to Class Mean Classifier

  • 1. Ahsanullah University of Science and Technology Department of Computer Science and Engineering Experiment No 1 Designing A Minimum Distance to Class Mean Classifier Pattern Recognition Lab CSE – 4214 Submitted By Name: Md. Toufique Hasan ID: 12.02.04.069 Year: 4th Semester: 2nd Section: B (B1) Date of Submission: 18-06-2016
  • 2. Designing A Minimum Distance to Class Mean Classifier Md. Toufique Hasan Department of Computer Science and Engineering Ahsanullah University of Science and Technology Dhaka, Bangladesh toufique.hasan@hotmail.com Objective The main objective of this assignment is to design a minimum distance to class mean classifier 1. Introduction Class Mean Classifier is used to classify unclassified sample vectors where the vectors are classified in more than one class. For example, in our dataset we have some sample vectors. Some given sample vectors are already classified into different classes and some are not classified. We can classify the unclassified sample vectors by the help of Minimum Distance to Class Mean Classifier. 2. Task Given the following two-class set of prototypes w1 = {(2,2), (3,1), (3,3), (-1,-3), (4,2), (-2,-2)} w2 = {(0,0), (-2,2), (-1,-1), (-4,2), (-4,3), (2,6)} a. Plot all sample points from both classes, but samples from the same class should have the same color and marker. b. 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 = (-1, -1) X2 = (3, 2) X3 = (-2, 1) X4 = (8, 2) Linear Discriminant Function: c. Draw the decision boundary between the two- classes. 3. Implementation a. First Step (Plot all sample points): Two classes are given. At first we have to plot all the sample points of both classes. Samples from the same class are plotted using the same color and marker. So that different classes can be distinguished easily. Here red stars ‘*’ represent class w1 and green stars ‘*’ represent class w2. Figure 1: Plot all the sample points b. Second Step (Classify the following points): The mean points of the two classes are calculated & plotted with same class color with the ‘O’ marker (‘O’ for class w1 & ‘O’ for class w2). Now for each of the point (X1, X2, X3, X4) we can calculate the distance from the calculate mean of each class using Linear Discriminant Function. Here red cross ‘x’ represent class w1 and green cross ‘x’ represent class w2. We use the same class color but different marker while plotting those points.
  • 3. Figure 2: Minimum distance classifier with respect to class mean & classify some samples c. Third Step (Drawing the decision boundary) In the last step, we will draw the decision boundary. For finding out the decision boundary we will consider all possible points within the range. We will consider those points as over the boundary line whose distance from both the classes are same. Here ‘-.’ line creates with blue color represents the linear decision boundary between the two classes. Figure 3: Drawing the decision boundary 4. MATLAB Code %Import Sample Points From Text Files w1 = zeros(2,10); myfile = fopen('w1.txt','r'); w1 = fscanf(myfile,'%f %f',size(w1)); w1 = w1'; w2 = zeros(2,10); myfile = fopen('w2.txt','r'); w2 = fscanf(myfile,'%f %f',size(w2)); w2 = w2'; %Plotting The Sample Points title('Designing a Minimum Distance to Class Mean Classifier','FontName','Comic Sans MS'); hold on; p1 = plot(w1(:,1),w1(:,2),'h','MarkerEd geColor','r','LineWidth',1.5); hold on; p2 = plot(w2(:,1),w2(:,2),'h','MarkerEd geColor','g','LineWidth',1.5); xlabel('X1'); ylabel('X2'); %Calculating Class Mean y1 = [mean(w1(:,1)),mean(w1(:,2))] y2 = [mean(w2(:,1)),mean(w2(:,2))] %Plotting Class Mean hold on p3 = plot(y1(1),y1(2),'o','MarkerEdgeCo lor','r','LineWidth',1.5); hold on p4 = plot(y2(1),y2(2),'o','MarkerEdgeCo lor','g','LineWidth',1.5); %Points for testing sample = zeros(2,10); myfile = fopen('sample.txt','r'); sample = fscanf(myfile,'%f %f',size(sample)); sample = sample';
  • 4. 5. Result Analysis We have taken two datasets for result analysis. Each classes in datasets contains 10 sample values. Some of them are classified and some are not. For dataset 1, 4 samples out of 10 from class 1 are misclassified with respect to decision boundary. And all the training samples are classified correctly. So, the accuracy is 80%. Figure 4: Result analysis for dataset 1 Now for dataset 2, 2 samples out of 10 from class 1 and 3 samples out of 10 from class 2 are miss classified with respect to decision boundary. And all the training samples are classified correctly. So, the accuracy is 75%. Figure 5: Result analysis for dataset 2 %Calculating Linear Discriminant Function for i = 1:length(sample) g1 = sample(i,:)*y1'- .5*(y1*y1'); g2 = sample(i,:)*y2'- .5*(y2*y2'); if g1 > g2 plot(sample(i,1),sample(i,2),'x',' MarkerEdgeColor','r','LineWidth',1 .5); else plot(sample(i,1),sample(i,2),'x',' MarkerEdgeColor','g','LineWidth',1 .5); end end %Decision Boundary Between Two- classes coefficient = y1-y2; constant = -0.5*det((y1' * y1)- (y2' * y2)); b = [-4:2:8]; for i = 1:length(b) y(:,i) = -((coefficient(1,1)* b(:,i)+constant)/coefficient(1,2)) ; end d_boundary = [b',y']; plot(d_boundary(:,1),d_boundary(:, 2),'-.b'); hold off;
  • 5. 6. Conclusion In this assignment some sample are classified and some are misclassified. I want to apply this assignment in an easy away. It has simple calculation. So that the speed of this result is too efficient. The main weakness of this algorithm is its misclassification rate is higher because the boundary between two classes is linear.