1.
Bayes algorithm:
Ex1.
Ex2.
Outlook Temp Humidity Windy Play
1 Sunny Hot High False No
2 Sunny Hot High True No
3 Overcast Hot High False Yes
4 Rainy Mild High False Yes
5 Rainy Cool Normal False Yes
6 Rainy Cool Normal True No
7 Overcast Cool Normal True Yes
8 Sunny Mild High False No
9 Sunny Cool Normal False Yes
10 Rainy Mild Normal False Yes
11 Sunny Mild Normal True Yes
12 Overcast Mild High True Yes
13 Overcast Hot Normal False Yes
14 Rainy Mild High True No
15 Sunny Cool High True ???
Hint:
Outlook Temp Humidity Windy Play
Yes No Yes No Yes No Yes No Yes No
Sunny 2 3 Hot 2 2 High 3 4 False 6 2 9 5
Overcast 4 0 Mild 4 2 Normal 6 1 True 3 3
Rainy 3 2 Cool 3 1
Sunny 2/9 3/5 Hot 2/9 2/5 High 3/9 4/5 False 6/9 2/5 9/14 5/14
Overcast 4/9 0/5 Mild 4/9 2/5 Normal 6/9 1/5 True 3/9 3/5
Rainy 3/9 2/5 Cool 3/9 1/5
2. Decision tree
Ex1.
Consider the training examples shown in Table for a binary classification problem
a) Compute the Gini index for the overall collection of training examples.
b) Compute the Gini index for the Customer ID attribute.
c) Compute the Gini index for the Gender attribute.
d) Compute the Gini index for the Car type attribute using multiway split.
e) Compute the Gini index for the Shirt Size using multiway split.
f) Which attribute is better, Gender, Car Type or Shirt size.
Ex.2:
Consider the training examples shown in Table for a binary classification problem
a) What is the entropy of this collection of training examples with respect to the positive class?
b) What is the best split (among a1, a2, a3) according to the information gain?
c) What is the best split (between a1 and a2) according to the Gini index?
3. KNN
Classify the data point x = 0.5 according to its 1-, 3-, 5-, and 9-nearest neighbors using
majority vote.
4. Association rules algorithm
Ex1:
a) compute the support for itemsets {e}, {b,d}, and {b, d, e} by treating each transaction ID
as a market basket.
b) Use the results in part (a) to compute the confidence for the association rules {b,d}→
{e} and {e} → {b,d}.
Ex2: