MATLAB TAKE HOME EXAM

profileaziz jaber
ECE443_Exam2_TakeHomePartNew2-2.pdf

PATTERN RECOGNITION EXAM 2 (TAKE HOME) DEADLINE: 11/1/2019 8:00AM

NAME: COURSE: EE443 / EE543

Problem 1 Develop a decision tree based on the following dataset, where C0 represents high school teachers and

C1 represents university staff. [50 points]

Part a) Develop the rule only for the root node. [20 points]

Part b) Repeat part (a) but with random numbers of records. Fill in the 4th column (the number of records) with

random numbers between 1 and 10. Use the MATLAB command “randi(10, [1 20])” to generate random numbers

for this column. It is ok to manipulate the random numbers so that they sum up to zero to simplify the calculations.

Similar numbers will be considered cheating, so make sure to generate your own numbers!!!. [30 Points]

Hint: This quiz is similar to Quiz 13, but we have multiple records for each type. In quiz 3, we have one of each

record. So, when calculating decision rules, we should be more careful and count the number of records. For

example, we have 3 records similar to the first record. We have a total of 50 records for class C0 and 50 for class

C1.

For example, here would be the result for decision rule based on gender

(𝐺 = 𝑀𝑎𝑙𝑒) ⟹ (10 + 4 + 5 + 7 + 3 + 10 𝑜𝑓 𝐶0 & 2 + 6 + 4 + 8 𝐶1)= (39𝐶0 & 20𝐶1)

(𝐺 = 𝐹𝑎𝑚𝑎𝑙𝑒) ⟹ (3 + 2 + 4 + 2 𝑜𝑓 𝐶0 & 5 + 4 + 5 + 4 + 7 + 5 𝐶1) = (11𝐶0 & 30𝐶1)

You can use MATLAB or excel with sorting columns for calculations.

Write all the steps.

Gender House Type Number of Children Number of records

Class

Female Single family house 2 3 C0

Male Apartment 2 10 C0

Male Single family house 1 4 C0

Male Single family house 2 5 C0

Male Apartment 1 7 C0

Male Apartment 1 3 C0

Male Apartment 0 10 C0

Female Apartment 1 2 C0

Female Single family house 2 4 C0

Female Single family house 2 2 C0

Female Single family house 1 5 C1

Female Apartment 0 4 C1

Male Apartment 0 2 C1

Male Apartment 0 6 C1

Male Apartment 1 4 C1

Male Single family house 2 8 C1

Female Single family house 1 5 C1

Female Apartment 0 4 C1

Female Apartment 1 7 C1

Female Single family house 2 5 C1

PATTERN RECOGNITION EXAM 2 (TAKE HOME) DEADLINE: 11/1/2019 8:00AM

NAME: COURSE: EE443 / EE543

Problem 2 (SVM Classifier) [50 points] Consider the following datasets

Animal type Class (y)

Height Feature: (F1)

Weight Feature: (F2)

Tail length Feature: (F3)

Dietary Feature: (F4)

1: Cats 10 ± 10% 8 ± 10% 12 ± 30% 1: OMNIVORE

2: Raccoons 12 ± 25% 9 ± 10% 10 ± 30% 1: OMNIVORE

3: Dogs 18 ± 30% 12 ± 40% 16 ± 50% 2: CARNIVORE

4: Zebras 160 ± 40% 5000 ± 30% 35 ± 10% 3: HERBIVORE

5: Horses 130 ± 30% 3700 ± 20% 35 ± 10% 3: HERBIVORE

6: Giraffes 200 ± 30% 4000 ± 10% 40 ± 30% 3: HERBIVORE

Where “x+y%” represents a Gaussian distribution with mean x and standard deviation x*y/100 similar to

HW7.

a) For each animal type calculate (500+F). F is the summation of the numerical values of the letters of your first

name. For, example if your name is James, F = J+A+M+E+S=10+1+13+5+19=48. [5 points]

b) Pool all training datasets and labels together (stack them). Shuffle the rows of the datasets and split the

dataset into (2/3) training samples and (1/3) test samples. [5 points]

c) Visualization: [5 points]

c.1) Plot all animals using the first two features (F1 and F2) in one Figure.

c.2) Plot CATS, DOGS, RACOONs using the first three features (F1 and F3) in one Figure.

d) Train a linear SVM classifier to classify Cats vs Raccoons (use training samples for training and test samples

for test). Calculate the error. [10 points]

e) Train a linear SVM classifier to classify Horses vs Zebra (use training samples for training and test samples for

test). Calculate the error. [5 points]

Consider only three animal types

Animal type Class (y)

Height Feature: (F1)

Weight Feature: (F2)

Tail length Feature: (F3)

Dietary Feature: (F4)

1: Cats 10 ± 10% 8 ± 10% 12 ± 30% 1: OMNIVORE

2: Raccoons 12 ± 25% 9 ± 10% 10 ± 30% 1: OMNIVORE

3: Dogs 18 ± 30% 12 ± 40% 16 ± 50% 2: CARNIVORE

f) Build 3-level classifier (linear SVM) and calculate the confusion matrix using one-vs-the rest method with the

following order (cats-raccoons- dogs) [10 points]

g) Repeat part (f), but use nonlinear SVM with RBF Kernel. Compare the results to part (f) and explain your

observation. [10 points]