Comp 1942 finalExamSol-2020
Comp 1942 finalExamSol-2020
Part A
Q1 (15 Marks) (Version 1)
Item Freq
a 3
b 5
c 7
d 7
e 1
f 7
g 1
h 1
i 1
j 1
k 1
l 1
m 1
n 1
o 1
p 1
q 1
r 1
s 1
t 1
Freq items:
Item Freq
a 3
b 5
c 7
d 7
f 7
FP-tree root
f
b a:1
d:3 f: 3
a
a:1
b:3
b:2
2/27
COMP1942 Suggested Answer
Conditional FP-tree on “a” count (a)=3
(d:1,f:1,a:1) (a:1,d:1)
(d:1,a:1) ⇒ (a:1,d:1)
(a:1) (a:1)
Item Freq
c 0
d 2
f 1
b 0
a 3
↓
Item Freq
a 3
d 2
root
Item Freq
c 3
d 5
f 2
b 5
a 0
↓
Item Freq
b 5
d 5
c 3
f 2 root
Item Head
d
d:5
c
f c:3
f:2
3/27
COMP1942 Suggested Answer
Conditional FP-tree on “b,f” count(b,f) = 2
(d:2,f:2) ⇒ (d:2,f:2)
root
Item Freq
d 2 d:2
{b,f}=2
{b,d,f}=2
Item Freq
d 3 d:3
{b,c}=3
{b,c,d}=3
root {b,d}:5
4/27
COMP1942 Suggested Answer
Item Head
d
d:3
Item Freq
c 3
d 7
f 0
b 0
a 0
↓
Item Freq
d 7
{c,d}:3
c 3 root
Item Head
c
c:3
Freq itemsets
={{c},{b,d}, {c,d}
{d},{a,d}, {b,c,d}
{f},{d,f}, {b, d, f},
{b}, {b,c}
{a},{b,f}}
5/27
COMP1942 Suggested Answer
Item Freq
a 1
b 1
c 1
d 1
e 1
f 1
g 1
h 1
i 1
j 1
k 1
l 1
r 3
s 5
t 6
u 7
v 1
w 7
x 1
y 1
z 1
Freq items:
Item Freq
r 3
s 5
t 6
u 7
w 7
6/27
COMP1942 Suggested Answer
FP-tree root
7/27
COMP1942 Suggested Answer
Item Freq
u 2
w 0
t 0
s 0
r 3
↓
Item Freq
r 3
u 2 root
Item Head
u
u:5
t
w
w:2 t:2
8/27
COMP1942 Suggested Answer
Item head
u {w,s}:2
u:2
{u,s,w}:2
9/27
COMP1942 Suggested Answer
Conditional FP-tree on “w” count (w)=7
(u:3,w:3) ⇒ (w:3,u:3)
(w:4) (w:4)
root
Item head
u {u,w}:3
u:3
(u:7)
root
Freq itemsets=
{ {u},{w},{t},{s}{r},
{r,u},{u,s},{w,s},{t,s},{u,t},{u,w}
{u,s,w},{u,s,t}
}
10/27
COMP1942 Suggested Answer
Q2 (15 Marks)
Center (1, 2) (2, 0) (-10, -5) (-5, -2) (10, 12) (8, 6) (-8, -6) (2, 1)
Points 1 2 3 4 5 6 7 8
(1, 2) 1 0
(2, 0) 2 2.24 0
(-10, -5) 3 13.04 13 0
(-5, -2) 4 7.21 7.28 5.83 0
(10, 12) 5 13.45 14.42 26.25 20.52 0
(8, 6) 6 8.06 8.49 21.1 15.26 6.32 0
(-8, -6) 7 12.04 11.66 2.24 5 25.46 20 0
(2, 1) 8 1.41 1 13.42 7.62 13.6 7.81 12.21 0
Center (1, 2) (2, 0.5) (-10, -5) (-5, -2) (10, 12) (8, 6) (-8, -6)
Points 1 (28) 3 4 5 6 7
(1, 2) 1 0
(2, 0.5) (28) 1.8 0
(-10, -5) 3 13.04 13.2 0
(-5, -2) 4 7.21 7.43 5.83 0
(10, 12) 5 13.45 14.01 26.25 20.52 0
(8, 6) 6 8.06 8.14 21.1 15.26 6.32 0
(-8, -6) 7 12.04 11.93 2.24 5 25.46 20 0
Center (1.5, 1.25) (-10, -5) (-5, -2) (10, 12) (8, 6) (-8, -6)
Points (128) 3 4 5 6 7
(1.5, 1.25) (128) 0
(-10, -5) 3 13.09 0
(-5, -2) 4 7.27 5.83 0
(10, 12) 5 13.7 26.25 20.52 0
(8, 6) 6 8.05 21.1 15.26 6.32 0
(-8, -6) 7 11.95 2.24 5 25.46 20 0
Center (1.5, 1.25) (-9, -5.5) (-5, -2) (10, 12) (8, 6)
Points (128) (37) 4 5 6
(1.5, 1.25) (128) 0
(-9, -5.5) (37) 12.48 0
(-5, -2) 4 7.27 5.32 0
(10, 12) 5 13.7 25.83 20.52 0
(8, 6) 6 8.05 20.52 15.26 6.32 0
11/27
COMP1942 Suggested Answer
12/27
COMP1942 Suggested Answer
Q3 (15 Marks)
(a)
Yes.
P(LC = Yes | FH = Yes, S = yes, PR = No) = 0.4375
(b) Disadvantages:
The Bayesian Belief network classifier requires a predefined knowledge about the network.
The Bayesian Belief Network classifier cannot work directly when the network contains cycles.
13/27
COMP1942 Suggested Answer
Q4 (15 Marks) (Version 1)
29/4 7.25
mean vector = = =
29/4 7.25
6 − 7.25 −5/4 −1.25
For data (6, 6), difference from mean vector = = =
6 − 7.25 −5/4 −1.25
8 − 7.25 3/4 0.75
For data (8, 8), difference from mean vector = = =
8 − 7.25 3/4 0.75
5 − 7.25 −9/4 −2.25
For data (5, 11), difference from mean vector = = =
11 − 7.25 15/4 3.75
10 − 7.25 11/4 2.75
For data (10, 4), difference from mean vector = = =
4 − 7.25 −13/4 −3.25
−1.25 0.75 −2.25 2.75
𝑌=
−1.25 0.75 3.75 −3.25
−1.25 −1.25
1 1 −1.25 0.75 −2.25 2.75 0.75 0.75
𝛴 = 𝑌𝑌 =
4 4 −1.25 0.75 3.75 −3.25 −2.25 3.75
2.75 −3.25
1 14.75 −15.25
=
4 −15.25 26.75
59 61
−
= 16 16 = 3.6875 −3.8125
61 107 −3.8125 6.6875
−
16 16
3.6875 − 𝜆 −3.8125
=0 ⇒ 𝜆 − 10.375𝜆 + 10.125 = 0
−3.8125 6.6875 − 𝜆
√ √
⇒ 𝜆= = 9.2845 or 𝜆 = = 1.0905
√
When 𝜆 = ,
59 83 + √4297 61
− −
16 𝑥 −61 𝑥 0
⎛16 16 ⎞ ⇒ −24 − √4297 =
61 107 83 + √4297 𝑥 −61 24 − √4297 𝑥 0
− −
⎝ 16 16 16 ⎠
⇒ 𝑥 + 0.6812𝑥 = 0
𝑥 0.5630
We choose the eigenvector of unit length: 𝑥 = .
−0.8265
√
when 𝜆 = ,
√ −
− 𝑥 −61 𝑥 0
𝑥 ⇒ −24 + √4297 𝑥 =
− −
√ −61 24 + √4297 0
⇒ 𝑥 − 1.4681𝑥 = 0
𝑥 −0.8265
We choose the eigenvector of unit length: 𝑥 = .
−0.5630
14/27
COMP1942 Suggested Answer
Order can be interchangeable from left-to-right
0.5630 −0.8265 0.5630 −0.8265
Thus, 𝛷 = ,𝑌=𝛷 𝑋= 𝑋.
−0.8265 −0.5630 −0.8265 −0.5630
15/27
COMP1942 Suggested Answer
87/4 21.75
mean vector = = =
87/4 21.75
18 − 21.75 −3.75
For data (18, 18), difference from mean vector = =
18 − 21.75 −3.75
24 − 21.75 2.25
For data (24, 24), difference from mean vector = =
24 − 21.75 2.25
15 − 21.75 −6.75
For data (15, 33), difference from mean vector = =
33 − 21.75 11.25
30 − 21.75 8.25
For data (30, 12), difference from mean vector = =
12 − 21.75 −9.75
−1.25 0.75 −2.25 2.75
𝑌=
−1.25 0.75 3.75 −3.25
−3.75 −3.75
1 1 −3.75 2.25 −6.75 8.25 2.25 2.25
𝛴 = 𝑌𝑌 =
4 4 −3.75 2.25 11.25 −9.75 −6.75 11.25
8.25 −9.75
1 132.75 −137.25
=
4 −137.25 240.75
33.1875 −34.3125
=
−34.3125 60.1875
33.1875 − 𝜆 −34.3125
=0
−34.3125 60.1875 − 𝜆
√ √
⇒ 𝜆= = 83.5602 or 𝜆 = = 9.8148
When 𝜆 = 83.5602,
33.1875 − 83.5602 −34.3125 𝑥 −50.3727 −34.3125 𝑥 0
𝑥 ⇒ 𝑥 =
−34.3125 60.1875 − 83.5602 −34.3125 −23.3727 0
⇒ 𝑥 + 0.6812𝑥 = 0
𝑥 0.5630
We choose the eigenvector of unit length: 𝑥 = .
−0.8265
when 𝜆 = 9.8148,
33.1875 − 9.8148 −34.3125 𝑥 23.3727 −34.3125 𝑥 0
−34.3125 60.1875 − 9.8148 𝑥 ⇒ −34.3125 50.3727 𝑥 =
0
⇒ 𝑥 − 1.4681𝑥 = 0
𝑥 −0.8265
We choose the eigenvector of unit length: 𝑥 = .
−0.5630
16/27
COMP1942 Suggested Answer
0.5630 −0.8265 24 −6.3241
For data (24, 24), 𝑌 = =
−0.8265 −0.5630 24 −33.3468
0.5630 −0.8265 15 −18.8291
For data (15, 33), 𝑌 = =
−0.8265 −0.5630 33 −30.9752
0.5630 −0.8265 30 6.9715
For data (30, 14), 𝑌 = =
−0.8265 −0.5630 12 −31.5499
−5.7312
The mean vector of the above transformed data points is =
−30.2205
The final transformed data points are:
17/27
COMP1942 Suggested Answer
Q5 (15 Marks)
(a)
Yes. The number is 3. By looking at the second portion of the chart, we have 10 – 7 = 3
(b)
Yes. The number is 7. By looking at the first portion of the chart, we have 7 – 0 = 7
(c)
Yes. The number is 6. By looking at the third portion of the chart, we have 16 – 10 = 6
(d)
Yes. The number is 14. By looking at the fourth portion of the chart, we have 30 – 16 = 14
(e)
Yes. The chart is shown as follows.
Decile mean/
Global mean
2.33 2.33
3
1.55
2
0.77 0.77
1
0 1 2 3 4 5 6 7 8 9 10 Decile
(f)
Yes.
18/27
COMP1942 Suggested Answer
Q6 (15 Marks)
19/27
COMP1942 Suggested Answer
Q7 (15 Marks)
(a)
ID x1 x2 y
a 13 13 1
b 19 9 1
c 21 15 1
d 15 19 1
e 7 9 -1
f 5 7 -1
g 9 9 -1
h 7 5 -1
(b)
minimize w12+w22
subject to
13w1 + 13w2 + b 1
19w1 + 9w2 + b 1
21w1 + 15w2 + b 1
15w1 + 19w2 + b 1
-7w1 – 9w2 – b 1
-5w1 – 7w2 – b 1
-9w1 -7w2 – b 1
-7w1 –5w2 – b 1
w1, w2 and b are real numbers
(c)
net=13w1 +13w1 +b=2.7
y=0.9910
w1 = 0.1+0.5*(1-0.9910)*13=0.1585
w2 = 0.1+0.5*(1-0.9910)*13=0.1585
b = 0.1+0.5*(1-0.9910)=0.1045
(d)
The neural network has an assumption that records in the training set are “independent”.
In some cases, records in the training set are related/correlated to (or dependent on) other records in the
training set. Thus, the neural network could not capture this “dependent” scenario well if the training set has
dependent records.
21/27
COMP1942 Suggested Answer
Q8 (15 Marks)
(a)
Adjacency matrix
(b)
Stochastic matrix
x y z
x 0 ½ ½
y ½ ½ ½
z ½ 0 0
(c)
1. Site x has to remove the link from site x to site y
2. Site x has to remove the link from site x to z
3. [Optional] Site x has to create a link from site x to itself
(d)
rn = 0.8 M r0 + c
rn ,1 m11 m12 m13 r0 ,1 0.2
rn , 2 = 0.8 m21 m22 m23 r0, 2 + 0.2
r m m32 m33 r 0.2
n ,3 31 0,3
22/27
COMP1942 Suggested Answer
Part B
Version 1
Version 2
23/27
COMP1942 Suggested Answer
Version 3
Version 4
24/27
COMP1942 Suggested Answer
Version 5
Version 6
25/27
COMP1942 Suggested Answer
Version 7
Version 8
26/27
COMP1942 Suggested Answer
Version 9
27/27