0% found this document useful (0 votes)
98 views

MachineLearning MidTerm UMT Spring 2021

This document contains a multi-part machine learning exam with questions on regression analysis, perceptron learning, classifier evaluation, decision tree learning, and K-nearest neighbors (KNN) algorithms. The exam includes datasets and asks students to perform tasks like fitting regression models, calculating perceptron outputs, evaluating a classifier at different thresholds, constructing a decision tree from training data, and making predictions using KNN. Students are asked to provide interpretations, apply learning algorithms, and make predictions based on different machine learning models.

Uploaded by

Zarfa Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

MachineLearning MidTerm UMT Spring 2021

This document contains a multi-part machine learning exam with questions on regression analysis, perceptron learning, classifier evaluation, decision tree learning, and K-nearest neighbors (KNN) algorithms. The exam includes datasets and asks students to perform tasks like fitting regression models, calculating perceptron outputs, evaluating a classifier at different thresholds, constructing a decision tree from training data, and making predictions using KNN. Students are asked to provide interpretations, apply learning algorithms, and make predictions based on different machine learning models.

Uploaded by

Zarfa Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

TAKE-HOME Exam: Machine Learning [Spring 2021]

Question #1: [Regression Analysis] [20 marks]

The data regarding the number of units produced of cars in thousands (X) and the average price of a car in
lacs (Y) in Spain were:

Sr. No. Cars Produced Average Car Price


(in thousands) (in millions)

1 30 2.5

2 28 3.0

3 32 2.7

4 25 4.0

5 25 4.2

6 25 4.0

7 22 5.0

8 24 4.5

9 35 3.0

10 40 2.5

A. Fit a linear regression model (i.e. find β0, β1):

B. What average cost would you predict for a car in a year when the total number of cars produced is
34,000?

C. What average cost would you predict for a car in a year when the total number of cars produced is
44,000?

D. What is the interpretation of β0?


E. What is the interpretation of β1?
Question #2: [Perceptron Learning] [25 marks]

Consider the following perceptron (with weights given on the connections).

-1.5
Xo

1
X1

1
X2

A. Fill in the table below to give the output of this perceptron on the following training set.

Bias = −1.5 Bias = −0.5


Weighted y Weighted y
Sum (Output Sum (Output
x1 x2 Target ) x1 x2 Target )
0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 1 1 1

B.
a. What is the accuracy of this perceptron on this training set using bias weight ‘-1.5’?

b. What is the accuracy of this perceptron on this training set using bias weight ‘-0.5’?

C. For the perceptron and training set above, apply the perceptron learning rule with stochastic
gradient descent for one epoch of training. Use a learning rate η = 1 and Bias (wo) = −1.5.
a. What are the weights after one epoch of training?

Example (x1=0, x2=0): Δw0 = --------, w0 = --------,

Δw1 = --------, w2 = --------,

Δw2 = --------, w2 = --------,

Target = ----, Output = ----


Example (x1=0, x2=1): Δw0 = --------, w0 = --------,

Δw1 = --------, w2 = --------,

Δw2 = --------, w2 = --------,

Target = ----, Output = ----

Example (x1=1, x2=0): Δw0 = --------, w0 = --------,

Δw1 = --------, w2 = --------,

Δw2 = --------, w2 = --------,

Target = ----, Output = ----

Example (x1=1, x2=1): Δw0 = --------, w0 = --------,

Δw1 = --------, w2 = --------,

Δw2 = --------, w2 = --------,

Target = ----, Output = ----

Final weights: w0 = ---------------- , w1 = ---------------- , w2 = ----------------


Question #3: [Classifier Evaluation] [15 marks]

Consider the table below, which reports, for eight instances, the actual class of each instance and the
score given by a classifier to that instance?

Instance Actual Class Score


1 Positive 6
2 Positive 3
3 Negative 2
4 Negative 1
5 Negative -2
6 Positive -3
7 Negative -4
8 Negative -5

For each value of the threshold in the table below, fill in the precision, and recall of the classifier. (If
the score is equal to or greater than the threshold, the classifier assigns “positive”, else it assigns
“negative”.)

Threshold Precision Recall (TPR) FPR


5
3

-3

-6
Question #4: [Decision Tree Learning] [20 marks]

Consider the following data set consisting of three input attributes: High-Income (H), Executive (E),
and Affiliation (A) and one binary output (Label).

The training examples are given below:


Sr. High-Income Executive Affiliation Suitable
No. (H) (E) (A) (Label)

1 Yes No Short No

2 No No Long No

3 Yes Yes Short Yes

4 Yes Yes Long Yes

5 Yes No Medium MNo

6 No No Long Yes

7 Yes Yes Long Yes

8 No Yes Medium No

9 No No Short Yes

10 Yes Yes Medium Yes

I. Use the Decision-Tree-Learning algorithm to draw a decision tree for the given data. (20)
II. How would your tree classify H =YES, E =YES, A =Long? (Write Suitable or Not-Suitable
according to the decision tree you have drawn) (4)

III. How would your tree classify H = YES, E =No, A =Short? (Write Suitable or Not-Suitable
according to the decision tree you have drawn) (3)

IV. How would your tree classify H = NO, E =YES, A =Medium? (Write Suitable or Not-Suitable
according to the decision tree you have drawn) (3)
Question #5: [K-NN] No marks without explanation [15 marks]

A. A KNN classifier assigns a test instance the majority class associated with its K nearest training
instances. Distance between instances is measured using Euclidean distance. Suppose we have the
following training set of positive (+) and negative (-) instances and a single test instance (o).
All instances are projected onto a vector space of two real-valued features (X and Y). Answer the
following questions.

I. What would be the class assigned to this test instance for K=3 [2]

II. What would be the class assigned to this test instance for K=5 [2]

III. What would be the class assigned to this test instance for K=7 [2]

IV. Setting K to a large value seems like a good idea. We get more votes! Given this particular
training set, would you recommend setting K = 11? Why or why not? [3]
Question #5:
B. The BurgerShop sells burgers with the following options: double eggs, shami-kabab and pickled
onion. Every day this week you have tried a burger (A to E) and kept a record of which you liked:
Double- Shami- Liked
Ex.No. Egg Kabab Salad (Class)
1 TRUE TRUE TRUE Disliked
2 TRUE FALSE FALSE Liked
3 FALSE TRUE TRUE Disliked
4 FALSE TRUE FALSE Liked
5 TRUE FALSE FALSE Liked
Use Hamming distance to calculate the neighbors:

I. How the 1NN classifier would classify {Double = false, Shami-kabab = false, Salad = true} [3]

II. How the 3NN classifier with majority voting would classify {Double = false, Shami-kabab = true,
Salad = true} [3]
Question #6: [Perceptron Learning] [25 marks]
Consider the three perceptrons below, which respectively correspond to classes A, B, and C. For a
given input x, the perceptron predicts the group with the highest value of Σ w i x i

For the following test set, find the prediction of this set of perceptrons on each example,
and create a corresponding confusion matrix.

Exampl Actual
e X1 X2 X3 Label
1 0 1 1 A
2 1 0 1 C
3 0 0 0 C
4 1 1 1 B
I. If x = (0, 1, 1) is the input to this group, which class is the prediction of the group?

II. If x = (1, 0, 1) is the input to this group, which class is the prediction of the group?

III. If x = (0, 0, 0) is the input to this group, which class is the prediction of the group?

IV. If x = (1, 1, 1) is the input to this group, which class is the prediction of the group?

CONFUSION MATRIX for Question #6:


ACTUA PREDICTED
L A B C
A
B
C

What is the Accuracy of the whole model?

You might also like