Starting from:

$40

PR ASSIGNMENT - 2 Design of Bayes Classifier Solved

PR ASSIGNMENT - 2
Design of Bayes Classifier 

 

Deliverables for this assignment: 

1.     Programming Assignment (MATLAB or Python) 

2.     Code file and output screenshots for all. You can make use of built in command to find the covariance matrix, where normalization is done using 1/ n-1.

 

Q1. Find and plot the decision boundary between class ω1 and ω2. Assume P(ω1) = P(ω2).

 

ω1 = [1,6; 3,4; 3,8; 5,6] 

ω2 = [3,0; 1,-2;3,-4;5,-2] 

 

 

 

Q2. Find and plot the decision boundary between class ω1 and ω2. Assume P(ω1) =0.3; P(ω2)=0.7 

 

ω1 = [1,-1; 2,-5; 3,-6; 4,-10; 5,-12; 6,-15] 

ω2 = [-1,1; -2,5; -3,6; -4,10, -5,12; -6, 15] 

 

        

Q3. Find and plot the decision boundary between class ω1 and ω2. Assume P(ω1) = P(ω2). 

 

ω1 = [2,6; 3,4; 3,8; 4,6] 

            ω2 = [3,0; 1,-2; 3,-4; 5,-2] 

 

Q4. Implement Bayes Classifier for Iris Dataset.  

Dataset Specifications:  

Total number of samples = 150 

Number of classes = 3 (Iris setosa, Iris virginica, and Iris versicolor) Number of samples in each class = 50  

 

Use the following information to design classifier:  

 

                         Number of training feature vectors ( first 40 in each class)  = 40  

                         Number of test feature vectors ( remaining 10 in each class) = 10 

                         Number of dimensions = 4  

                          Feature vector = <sepal length, sepal width, petal length, petal width 

 

If the samples follow a multivariate normal density, find the accuracy of classification for the test feature vectors. 

 

  

 

Q5. Use only two features: Petal Length and Petal Width, for 3 class classification and draw the decision boundary between them (2 dimension, 3 regions also called as multi-class problem) 

 

    

Q6. Consider the 128- dimensional feature vectors given in the “face feature vectors.csv” file. Use this information to design and implement a Bayes Classifier.  

 

Dataset Specifications:  

Total number of samples = 800 

Number of classes = 2 ( labelled as “male” and “female”)  

Samples from “1 to 400”  belongs to class “male” 

Samples from “401 to 800” belongs to class “female” 

Number of samples per class = 400 

 

Use the following information to design classifier:  

 

                        Number of test feature vectors ( first 5 in each class)  = 5  

                        Number of training feature vectors ( remaining 395 in each class) = 395                         Number of dimensions = 128  

                         

 

  

Design of Bayes Classifier

 

Given, 

Iris dataset    

   𝑋 =< 𝑥1 , 𝑥2, 𝑥3, 𝑥4

   Number of classes= 𝜔1, 𝜔2, 𝜔3 ;  c=3 

   N=150; n(𝜔1)=n(𝜔1)=n(𝜔1)=50 Bayes Rule: 

  

  Find 𝑃(𝜔𝑖|𝑋) = 𝑃 (𝑋|𝜔𝑃(𝑖𝑋)).𝑃(𝜔𝑖)  

    

𝑃(𝑋) is a constant for all classes; so it can be ignored. 

 

  

 

 

 

Steps to follow in Iris Classification:

 

1.  Find apriori probability  𝑃(𝜔𝑖) = 𝑛 (𝑁𝜔𝑖) =   

2.  Find  𝑃(𝑋|𝜔𝑖),  it’s multivariate class, by following normal density 

     

               𝑃(𝑋|𝜔𝑖) =  ( 2𝜋)𝑑/21 |𝛴𝑖|1/2 𝑒𝑥𝑝 [−   {(𝑋 − µ𝑖)𝑡𝛴𝑖−1(𝑋 − µ𝑖)}]

             

                        2 a. Find the mean vector 

                        2 b. Find the covariance matrix, 𝛴𝑖  

                         2 c. Find the |𝛴𝑖| and |𝛴𝑖|−1

3.  Find 𝑃(𝜔1|𝑋),  𝑃(𝜔2|𝑋) 𝑎𝑛𝑑 𝑃(𝜔3|𝑋).  Find the maximum and assign 𝑋 to that class. Also, plot the accuracy for :     i) Separate classes          ii) Overall performance 

4.  Find the discriminant function and draw the decision surface between the classes. 

 

 

 

Note: The same steps can be followed for Q6. 

****************************************************************************** 

                             

More products