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

Final exam answers (1)

The document provides answers to a final exam in machine learning, including calculations for the Gini index of various attributes and clustering of points into three clusters. It details the Gini index calculations for weather, parent, and money attributes, concluding that the minimum Gini index is for the parent attribute. Additionally, it describes the clustering process with initial centroids and the final clusters formed.

Uploaded by

hanayaregal13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Final exam answers (1)

The document provides answers to a final exam in machine learning, including calculations for the Gini index of various attributes and clustering of points into three clusters. It details the Gini index calculations for weather, parent, and money attributes, concluding that the minimum Gini index is for the parent attribute. Additionally, it describes the clustering process with initial centroids and the final clusters formed.

Uploaded by

hanayaregal13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Machine Learning Final Exam Answers

Final exam answers


IV. Give necessary answers for the following questions.

1. Based on the above dataset


A) Find the gini index of each attributes. ( 5 points)
B) Draw decision tree that contains the pure class.

➢ There are 6 cinema, 2 tennis, 1 stay in, 1 shopping


Then, the Gin index of sample
6
Gini(s)=1 - [( )2 + (10
2
)2 + (10
1
)2 + (10
1
)2] = 0.58
10

✓ Gini index of weather, it has values of: 3 sunny, 4 windy and 3 rainy

Page | 1
Machine Learning Final Exam Answers
For weather, sunny: 1 cinema and 2 tennis, then
1 2
Gin(sunny)=1- [( )2 + ( )2]= 0.444
3 3

For weather, windy: 3 cinema and 1 shopping, then


3 1
Gin(windy)=1- [( )2 + ( )2]= 0.375
4 4

For weather, rainy: 2 cinema and 1 stay in, then


2 1
Gin(windy)=1- [( )2 + ( )2]= 2
3 3

Weighted weather Gin index


3 4 4
Gin(Weather)= 0.444* +0.375* +2* =1.083
10 10 10

✓ Gini index of parent, it has values of: 5 yes and 5 no


For parent, yes: 5 cinema, then
5
Gin(yes)=1- [( )2 ]=0
5

For parent, no: 1 cinema,2 tennis,1 stay in and 1 shopping, then


1 2 1 1
Gin(no)=1- [( )2 + ( )2+ ( )2 + ( )2]=0.28
5 5 5 5

Weighted parent Gin index


5 5
Gin(parent)= 0* +0.28* =0.14
10 10

✓ Gini index of money, it has values of: 3 poor and 7 rich


For money, poor: 3 cinema, then
3
Gin(poor)=1- [( )2 ]=0
3

For money, rich: 3 cinema,2 tennis,1 stay in and 1 shopping, then


3 2 1 1
Gin(rich)=1- [( )2 + ( )2+ ( )2 + ( )2]= 0.306
7 7 7 7

Weighted money Gin index

Page | 2
Machine Learning Final Exam Answers
3 7
Gin(money)= 0* +0.306* =0.2142
10 10

❖ Therefore the Gin index


Gini(weather)=1.083
Gini(parent)=0.14
Gini(money)=0.2142
So, the best is minimum Gini(parent)=0.14

start

yes no

2. Cluster the following eight points (with (x, y) representing locations) into three
clusters :
A1(3, 10) A2(6, 5) A3(9, 4) A4(7, 8) , A5(10, 6) A6(2,
4) A7(2,2), A8(4, 9).
Assume that initial cluster centers are:
A1(3, 10), A4(7,8) and A7(2, 2).

Points A1(3, 10) A4(7,8) A7(2, 2) Clusters


A1(3, 10) 0 6 9 C1
A2(6, 5) 8 4 7 C2
A3(9, 4) 12 6 9 C2
A4(7, 8) 6 0 11 C2
A5(10, 6) 11 5 12 C2
A6(2, 4) 7 9 2 C3
Page | 3
Machine Learning Final Exam Answers
A7(2,2) 9 11 0 C3
A8(4, 9) 2 4 9 C1

❖ New centroid in Cluster 1(C1):


A1(3, 10) and A8(4, 9) = ((3+4)/2,(10+9)/2) = (3.5,9.5)
❖ New centroid in Cluster 2(C2):
A2(6, 5), A3(9, 4), A4(7, 8), A5(10, 6) = (6+9+7+10)/4, (5+4+8+6)/4)
= (8,5.75)
❖ New centroid in Cluster 3(C3):
A6(2, 4) and A7(2,2) = ((2+2)/2,(4+2)/2) = (2,3)

Points C1(3.5,9.5) C2(8,5.75) C3(2, 3) Clusters


A1(3, 10) 1 9.25 8 C1
A2(6, 5) 7 2.75 6 C2
A3(9, 4) 11 2.75 8 C2
A4(7, 8) 5 3.25 10 C2
A5(10, 6) 10 2.25 11 C2
A6(2, 4) 7 7.75 1 C3
A7(2,2) 9 9.75 1 C3
A8(4, 9) 1 7.25 8 C1

❖ New centroid in Cluster 1(C1):


A1(3, 10) and A8(4, 9) = ((3+4)/2,(10+9)/2) = (3.5,9.5)
❖ New centroid in Cluster 2(C2):
A2(6, 5), A3(9, 4), A4(7, 8), A5(10, 6) = (6+9+7+10)/4, (5+4+8+6)/4)
= (8,5.75)
❖ New centroid in Cluster 3(C3):
A6(2, 4) and A7(2,2) = ((2+2)/2,(4+2)/2) = (2,3)

Page | 4
Machine Learning Final Exam Answers
➢ The clustering step is stopped, because the new centroid and the previous
centroid are the same.

Cluster 1 Cluster 2 Cluster 3


A1(3, 10) A2(6, 5) A6(2, 4)
A8(4, 9) A3(9, 4) A7(2,2)
A4(7, 8)
A5(10, 6)

Page | 5

You might also like