MachineLearning MidTerm UMT Spring 2021
MachineLearning MidTerm UMT Spring 2021
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:
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
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?
-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.
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?
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?
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”.)
-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).
1 Yes No Short No
2 No No Long No
6 No No Long Yes
8 No Yes Medium No
9 No No Short 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?