You are on page 1of 3

COMSATS University, Islamabad

Department of Computer Science


Second Sessional Examination Spring-2019
Subject: Machine Learning/Introduction to Machine Learning
Semester: BS (CS) –VI, VII Marks: 15
Dated: 29th April, 2019 Time: One Hour
Instructor: Tehseen Zia, Umar Nauman, Rizwan Rashid

Name: ______________________ Reg. No:


____________________
Instructions:
 Solve Question 01(a) on question paper only (in the provided space only) and (b) on
answer sheet. Note that, you have to attempt any one of (a) or (b)
 Fill in table for Question 02 on question paper only
 Return question paper with answer sheet, failing to do so will result in cancellation of
exam and zero credit in sessional 2.
---------------------------------------------------- CLO 2 ---------------------------------------------------
-
Question 01 (a): (1 + 2 + 2 + 2 = 07
marks)
A study was made by a retail merchant to determine the relation between weekly advertising
expenditure and sales. The following data was collected:
Table 1: weekly advertising expenditure and sales
Advertising Sales x-xbar y-ybar (x-xbar)(y-ybar) (x- y^ = 1.01786*x y-y^ (y-y^)2
Cost (X) (Y) xbar)2 + 376
40 385 13 -19 -247 169 416.71 - 1005.5
31.71
20 400 -7 -4 28 49 396.35 3.65 13.32
25 395 -2 -9 18 4 401.44 -6.44 41.47
20 365 -7 -39 273 49 396.35 - 982.82
31.35
30 475 3 71 213 9 406.53 68.47 4688.14
135 2020 0.00 0.00 285 280 6731.25
a) Plot scatter diagram
b) Find the equation of regression line to predict weekly sales
c) Estimate weekly sale for advertising cost of $35
d) Find root mean squared error/R2 Method

xbar = 135/5 = 27
ybar = 2020/5 = 404

y = m*x + b

m = sum of ((x-xbar)(y-ybar)) / sum of (x-xbar)2 = 285/280 = 1.01786

b = ybar – m*xbar = 404 – (1.01786)(27) = 376.51

y = 1.01786*x + 376.51

y for x = 35
y = 1.01786*35 + 376.51 = 412.14
Page 1 of 3
COMSATS University, Islamabad
Department of Computer Science
Second Sessional Examination Spring-2019
RMSE = (sum of (predicted – actual)2 / n )1/2

= (6731.25 / 5)1/2 = (1346.25)1/2 = 36.69


(OR)
--------------------------------------------------- CLO 3 ----------------------------------------------------
(b) Consider the dataset given below and apply the Naïve Bayesian classifier and classify the
unknown data sample, given below: (07 marks)
X = {age ≤ 30, income = medium, student = yes, credit-rating = fair}
Table 2: Dataset of Buy computer concept
Class: Buy-
Id Age Income Student Credit- rating
computer
1 < 30 High No Fair No
2 < 30 High No Excellent No
3 30-40 High No Fair Yes
4 > 40 Medium No Fair Yes
5 > 40 Low Yes Fair Yes
6 > 40 Low Yes Excellent Yes
7 30-40 Low Yes Excellent Yes
8 < 30 Medium No Fair No
9 < 30 Low Yes Fair Yes
10 > 40 Medium Yes Fair Yes

N = 10

P (yes) = 7/10
P (no) = 3/10

P (age < 30 | buys_computer = yes) = 1/7


P (age < 30 | buys_computer = no) = 3/3

P (income = medium | buys_computer = yes) = 2/7


P (income = medium | buys_computer = no) = 1/3

P (CR = fair | buys_computer = yes) = 5/7


P (CR = fair | buys_computer = no) = 2/3

P (student = yes | buys_computer = yes) = 5/7


P (student = yes | buys_computer = no) = 3/3

buy computer = yes 0,014577259


buy computer = no 0,066666667

Answer = Student will buy computer

Page 2 of 3
COMSATS University, Islamabad
Department of Computer Science
Second Sessional Examination Spring-2019
----------------------------------------------------- CLO 3 --------------------------------------------------

Question 02: (6 + 2 = 08 marks)

Consider the following network architecture with learning rate 0.1 and having values as
I1 I2 W1 W2 W3 W4 W5 W6 out
2 3 0.11 0.21 0.12 0.08 0.14 0.15 1

W1
I1 h1
W5

W2

out
W3
W6

W4
I2 h2

Calculate the values and fill in the table using sigmoid as activation function. Also
perform error calculation and update only w5 using Back Propagation

Input for hidden Output for Input for output Updated weight
layer hidden layer(sigmoid) output layer
h1(in) h2(in) h1(out) h2(out) Out(in) Out(out) W/ 5
0,85 0,48

Page 3 of 3

You might also like