ML Assignment Week 4 2019 Nptel
ML Assignment Week 4 2019 Nptel
Assignment- Week 4
TYPE OF QUESTION: MCQ
Number of questions: 7 Total mark: 7 X 2 = 14
______________________________________________________________________________
QUESTION 1:
A spam filtering system has a probability of 0.95 to correctly classify a mail as spam and 0.10
probability of giving false positives. It is estimated that 1% of the mails are actual spam mails.
Suppose that the system is now given a new mail to be classified as spam/ not-spam, what is the
probability that the mail will be classified as spam?
A. 0.89575
B. 0.10425
C. 0.1085
D. 0.0995
Detailed Solution:
Let S = ‘Mails correctly marked spam by the system’, T= ‘Mails misclassified by the
system’(Marked as spam when not spam or Marked as not spam when it is a spam) , M=
‘Spam mails’.
We have to find the probability of mail being classified as spam which can either be if a spam
mail is correctly classified as spam or if a mail is misclassified as spam.
______________________________________________________________________________
QUESTION 2:
Bag I contains 4 white and 6 black balls while another Bag II contains 4 white and 3 black balls.
One ball is drawn at random from one of the bags and it is found to be black. Find the probability
that it was drawn from Bag I.
A. 1/2
B. 2/3
C. 7/12
D. 9/23
Detailed Solution :
B1: “Ball is drawn from bag I”, B2: “Ball is drawn from bag II”, W: “Drawn ball is white”,
B: “Drawn ball is black”
______________________________________________________________________________
QUESTION 3:
4. Consider the following Bayesian network, where F = having the flu and C = coughing:
A. 0.35, 0.23
B. 0.35,0.77
C. 0.24, 0.024
D. 0.5, 0.23
Detailed Solution :
______________________________________________________________________________
QUESTION 4:
Consider the following Bayesian network.
Thus, the independence expressed in this Bayesian net are that
A and B are (absolutely) independent.
C is independent of B given A.
D is independent of C given A and B.
E is independent of A, B, and D given C.
Find 𝑃(𝐷).
A. 0.32
B. 0.50
C. 0.40
D. 0.78
Correct Answer: A. 0.32
Detailed Solution :
𝑃(𝐷) = 𝑃(𝐷|𝐴𝐵) * 𝑃(𝐴𝐵) + 𝑃(𝐷|𝐴𝐵) * 𝑃(𝐴𝐵) + 𝑃(𝐷|𝐴𝐵) * 𝑃(𝐴𝐵) + 𝑃(𝐷|𝐴 𝐵) * 𝑃(𝐴 𝐵) = 0. 32
____________________________________________________________________________
QUESTION 5:
Consider the following graphical model, mark which of the following pair of random variables
are independent given no evidence?
A. a,b
B. c,d
C. e,d
D. c,e
Correct Answer : A. a,b
Detailed Solution : Nodes a and b don’t have any predecessor nodes. As they don’t have any
common parent node, a and b are independent.
_____________________________________________________________________________
QUESTION 6:
In a Bayesian network a node with only outgoing edge(s) represents
Detailed Solution : As there is no incoming edge for the node, the node is not conditionally
dependent on any other node.
______________________________________________________________________________
QUESTION 7:
It is given that 𝑃(𝐴|𝐵) = 2/3 and 𝑃(𝐴|𝐵) = 1/3. Compute the value of 𝑃(𝐵|𝐴).
A. ½
B. ⅔
C. ¾
D. Not enough information.
Correct Solution : D. Not enough information.
Detailed Solution : There are 3 unknown probabilities 𝑃(𝐴), 𝑃(𝐵), 𝑃(𝐴𝐵)which can not be
computed from the 2 given probabilities. So, we don’t have enough information to compute
𝑃(𝐵|𝐴).
______________________________________________________________________________
************END*******
Introduction to Machine Learning
Assignment- Week 4
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 X 2 = 20
______________________________________________________________________________
QUESTION 1:
A man is known to speak the truth 2 out of 3 times. He throws a die and reports that the number
obtained is 4. Find the probability that the number obtained is actually 4 :
A. 2/3
B. 3/4
C. 5/22
D. 2/7
2
𝑃(𝐵|𝐴) = 7
_________________________________________________________________
QUESTION 2:
Consider the following graphical model, mark which of the following pair of random variables
are independent given no evidence?
A. a,b
B. c,d
C. e,d
D. c,e
Correct Answer : A. a,b
Detailed Solution : Nodes a and b don’t have any predecessor nodes. As they don’t have any
common parent nodes, a and b are independent.
______________________________________________________________________________
QUESTION 3:
Two cards are drawn at random from a deck of 52 cards without replacement. What is the
probability of drawing a 2 and an Ace in that order?
A. 4/51
B. 1/13
C. 4/256
D. 4/663
Detailed Solution :
A : Drawing a 2
1*4 4
𝑃(𝐴𝐵) = 13*51
= 663
______________________________________________________________________________
QUESTION 4:
Consider the following Bayesian network. The random variables given in the model are
modeled as discrete variables (Rain = R, Sprinkler = S and Wet Grass = W) and the
corresponding probability values are given below.
P(R) = 0.1
P(S) = 0.2
P(W | R, S) = 0.8
P(W | R, ¬ S) = 0.7
P(W | ¬ R, S) = 0.6
P(W | ¬ R, ¬ S) = 0.5
A. 1
B. 0.5
C. 0.22
D. 0.78
𝑃(𝑊,𝑆,𝑅) 𝑃(𝑊𝑆𝑅)
Detailed Solution : 𝑃(𝑆|𝑊, 𝑅) = 𝑃(𝑊,𝑅)
=
𝑃(𝑊𝑆𝑅)+𝑃(𝑊𝑆𝑅)
𝑃(𝑊𝑆𝑅) = 𝑃(𝑊|𝑆, 𝑅) * 𝑃(𝑅) * 𝑃(𝑆) = 0. 8 * 0. 1 * 0. 2 = 0. 016
𝑃(𝑊𝑆𝑅) = 𝑃(𝑊|𝑆, 𝑅) * 𝑃(𝑅) * 𝑃(𝑆) = 0. 7 * 0. 1 * 0. 8 = 0. 056
____________________________________________________________________________
QUESTION 5:
What is the naive assumption in a Naive Bayes Classifier?
Correct Answer: B. All the features of a class are independent of each other
Detailed Solution: Naive Bayes Assumption is that all the features of a class are independent of
each other which is not the case in real life. Because of this assumption, the classifier is called
Naive Bayes Classifier.
_____________________________________________________________________________
QUESTION 6:
A drug test (random variable T) has 1% false positives (i.e., 1% of those not taking drugs show
positive in the test), and 5% false negatives (i.e., 5% of those taking drugs test negative).
Suppose that 2% of those tested are taking drugs. Determine the probability that somebody who
tests positive is actually taking drugs (random variable D).
A. 0.66
B. 0.34
C. 0.50
D. 0.91
______________________________________________________________________________
QUESTION 7:
It is given that 𝑃(𝐴|𝐵) = 2/3 and 𝑃(𝐴|𝐵) = 1/4. Compute the value of 𝑃(𝐵|𝐴).
A. ½
B. ⅔
C. ¾
D. Not enough information.
Correct Solution : D. Not enough information.
Detailed Solution : There are 3 unknown probabilities 𝑃(𝐴), 𝑃(𝐵), 𝑃(𝐴𝐵)which can not be
computed from the 2 given probabilities. So, we don’t have enough information to compute
𝑃(𝐵|𝐴).
______________________________________________________________________________
QUESTION 8:
Answer Questions 8-9 with the data given below:
A patient goes to a doctor with symptoms S1, S2 and S3. The doctor suspects disease D1and D2
and constructs a Bayesian network for the relation among the disease and symptoms as the
following:
Correct Answer: D.
Detailed Solution: From the figure, we can see that D1 and D2 are not dependent on any
variable as they don’t have any incoming directed edges. S1 has an incoming edge from D1,
hence S1 depends on D1. S2 has 2 incoming edges from D1 and D2, hence S2 depends on D1
and D2. S3 has an incoming edge from D2, S3 depends on D2. Hence, (D) is the answer.
______________________________________________________________________________
QUESTION 9:
Suppose P(D1) = 0.5, P(D2)=0.6 , P(S1|D1)=0.4 and P(S1| D1’ )= 0.6. Find P(S1)
A. 0.14
B. 0.36
C. 0.50
D. 0.66
Detailed Solution:
______________________________________________________________________________
QUESTION 10:
In a Bayesian network a node with only outgoing edge(s) represents
Detailed Solution : As there is no incoming edge for the node, the node is not
conditionally dependent on any other node.
___________________________________________________________________________
************END*******
Introduction to Machine Learning -IITKGP
Assignment - 4
TYPE OF QUESTION: MCQ/MSQ
Number of questions: 15 Total mark: 2 * 15 = 30
Q1.
Suppose that the system is now given a new mail to be classified as spam/ not-spam, what is
the probability that the mail will be classified as spam?
a. 0.89575
b. 0.10425
c. 0.00475
d. 0.09950
Correct Answer: b
Detailed Solution:
Let S = ‘Mails correctly marked spam by the system’, T= ‘Mails misclassified by the
system’(Marked as spam when not spam or Marked as not spam when it is a spam) , M = ‘Spam
mails’.
We are to find the probability of mail being classified as spam which can either be if a spam
mail is correctly classified as spam or if a mail is misclassified as spam.
d. 0.99525
Correct Answer: a
Q3. Given that a mail is classified as not spam, the probability of the mail actually being not
spam
a. 0.10425
b. 0.89575
c. 0.003
d. 0.997
Correct Answer: d
a. 0.90025
b. 0.09975
c. 0.8955
d. 0.1045
Correct Answer: b
= 0.09975
Correct Answer: b
Detailed Solution:
Naive Bayes Assumption is that all the features of a class are independent of each other
which is not the case in real life. Because of this assumption, the classifier is called Naive
Bayes Classifier.
Q6.
Consider the following dataset. a,b,c are the features and K is the class(1/0):
a b c K
1 0 1 1
1 1 1 1
0 1 1 0
1 1 0 0
1 0 1 0
0 0 0 1
Classify the test instance given below into class 1/0 using a Naive Bayes Classifier.
a b c K
0 0 1 ?
a. 0
b. 1
Correct Answer: b
Detailed Solution:
𝑃(𝐾=1)∗𝑃(𝑎=0|𝐾=1)∗𝑃(𝑏=0|𝐾=1)∗𝑃(𝑐=1|𝐾=1)
P(K=1|a=0, b=0, c=1) = [By Naive Bayes’
𝑃(𝑎=0,𝑏=0,𝑐=1)
Assumption]
3 1 2 2
= 6 ∗ 3 ∗ 3 ∗ 3[The denominator can be ignored since all the features
have the same probability for each class]
= 0.07407
3 1 1 2
P(K=0| a=0, b=0, c=1) = 6 ∗ 3 ∗ 3 ∗ 3 = 0.03703 < 0.07407
1
c.
9
8
d.
9
Correct Answer: b
Detailed Solution:
𝑃(𝐾 = 0|𝑎 = 1, 𝑏 = 1)
𝑃(𝐾 = 0) ∗ 𝑃(𝑎 = 1|𝐾 = 0) ∗ 𝑃(𝑏 = 1|𝐾 = 0) 2
= =
𝑃(𝐾 = 0) ∗ 𝑃(𝑎 = 1|𝐾 = 0) ∗ 𝑃(𝑏 = 1|𝐾 = 0) + 𝑃(𝐾 = 1) ∗ 𝑃(𝑎 = 1|𝐾 = 1) ∗ 𝑃(𝑏 = 1|𝐾 = 1) 3
Q8.
Answer Questions 8-10 with the data given below:
A patient goes to a doctor with symptoms S1, S2 and S3. The doctor suspects disease D1and
D2 and constructs a Bayesian network for the relation among the disease and symptoms as
the following:
Detailed Solution:
From the figure, we can see that D1 and D2 are not dependent on any variable as they don’t
have any incoming directed edges. S1 has an incoming edge from D1, hence S1 depends on
D1. S2 has 2 incoming edges from D1 and D2, hence S2 depends on D1 and D2. S3 has an
incoming edge from D2, S3 depends on D2. Hence, (d) is the answer.
Q9. Suppose P(D1) = 0.4, P(D2) = 0.7 , P(S1|D1)=0.3 and P(S1| D1’)= 0.6. Find P(S1)
a. 0.12
b. 0.48
c. 0.36
d. 0.60
Correct Answer: b
Detailed Solution:
a. D1
b. D2
c. D1 and D2
d. None
Correct Answer: b
Detailed Solution:
● X’s parents
● X’s children
● Parents of X’s children
In the given diagram, variable, S2 has a parent D2 and no children. Hence, the correct answer
is (b).
___________________________________________________________________________
Q11. Consider the following Bayes’ network:
Alarm1 means that the first alarm system rings, Alarm2 means that the second alarm system
rings, and Burglary means that a burglary is in progress. Now assume that:
P(Alarm1) = 0.1
P(Alarm2) = 0.2
P (Burglary | Alarm1, Alarm2) = 0.8
P (Burglary | Alarm1, ¬Alarm2) = 0.7
P (Burglary | ¬Alarm1, Alarm2) = 0.6
P (Burglary | ¬Alarm1, ¬Alarm2) = 0.5
Calculate P (Alarm2 | Burglary, Alarm1).
a. 0.78
b. 0.22
c. 0.50
d. 0.10
Correct Answer: b
Detailed Solution:
The values of the conditional probabilities are given below. Find 𝑃(𝐷).
Assume,
𝑃(𝐴) = 0.3
𝑃(𝐵) = 0.6
𝑃(𝐶|𝐴) = 0.8
𝑃(𝐶|𝐴) = 0.4
𝑃(𝐷|𝐴, 𝐵) = 0.7
𝑃(𝐷|𝐴, 𝐵) = 0.8
𝑃(𝐷|𝐴, 𝐵) = 0.1
𝑃(𝐷|𝐴, 𝐵) = 0.2
𝑃(𝐸|𝐶) = 0.7
𝑃(𝐸|𝐶) = 0.2
a. 0.68
b. 0.32
c. 0.50
d. 0.70
Correct Answer: b
Detailed Solution:
P(C) = P(C|A) * P(A) + P(C|𝐴) * P (𝐴) = 0.8 * 0.3 + 0.4 * 0.7 = 0.24 + 0.28 = 0.52
Q13.
Answer Questions 13-14 with the data given below:
In an oral exam you have to solve exactly one problem, which might be one of three types, A,
B, or C, which will come up with probabilities 30%, 20%, and 50%, respectively. During your
preparation you have solved 9 of 10 problems of type A, 2 of 10 problems of type B, and 6 of
10 problems of type C.
What is the probability that you will solve the problem of the exam?
a. 0.61
b. 0.39
c. 0.50
d. 0.20
Correct Answer: a
Detailed Solution:
A: Problem of type A.
B: Problem of type B.
C: Problem of type C.
S: You solve the problem
P(A) = 0.30
P(B) = 0.20
P(C) = 0.50
P(S|A) = 9/10
P(S|B) = 2/10
P(S|C) = 6/10
P(S) = P(S|A) P(A) + P(S|B) P(B) + P (S|C) P(C)
= (9/10) * (0.30) + (2/10) * (0.20) + (6/10) * (0.50)
= 0.61
Q14. Given you have solved the problem, what is the probability that it was of type A?
a. 0.35
b. 0.50
c. 0.56
d. 0.44
Correct Answer: d
Detailed Solution:
A: Problem of type A.
S: You solve the problem
P(A) = 0.30
P(S|A) = 9/10
P(S) = 0.61
𝟗
𝑷(𝑺|𝑨)∗ 𝑷(𝑨) ( )(𝟎.𝟑𝟎)
P(A|S) = == 𝟏𝟎
= 0.4426
𝑷(𝑺) (𝟎.𝟔𝟏)
Q15. Naive Bayes is a popular classification algorithm in machine learning. Which of the
following statements is/are true about Naive Bayes?
a. Naive Bayes assumes that all features are independent of each other, given the class.
b. It is particularly well-suited for text classification tasks, like spam detection.
c. Naive Bayes can handle missing values in the dataset without any special treatment.
d. It is a complex algorithm that requires a large amount of training data.
Correct Answers: a, b
Explanation:
a. Correct. Naive Bayes assumes that features are conditionally independent given the class.
This simplifying assumption allows the algorithm to estimate probabilities efficiently even
with a limited amount of data.
b. Correct. Naive Bayes is commonly used for text classification tasks, such as spam detection
and sentiment analysis, due to its ability to handle high-dimensional feature spaces.
c. Incorrect. Naive Bayes does not handle missing values naturally. Missing values need to be
handled before applying the algorithm.
d. Incorrect. Naive Bayes is actually known for its simplicity and ability to work well with
small amounts of training data. It is not considered complex and often provides good results
with relatively simple computations.
*******END*******
Introduction to Machine Learning
Assignment- Week 4
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 X 2 = 20
______________________________________________________________________
QUESTION 1:
A man is known to speak the truth 2 out of 3 times. He throws a die and reports that the
number obtained is 4. Find the probability that the number obtained is actually 4 :
A. 2/3
B. 3/4
C. 5/22
D. 2/7
2
𝑃(𝐵|𝐴) = 7
_________________________________________________________________
QUESTION 2:
Two cards are drawn at random from a deck of 52 cards without replacement. What is
the probability of drawing a 2 and an Ace in that order?
A. 4/51
B. 1/13
C. 4/256
D. 4/663
A : Drawing a 2
1*4 4
𝑃(𝐴𝐵) = 13*51
= 663
______________________________________________________________________
QUESTION 3:
Consider the following graphical model, mark which of the following pair of random
variables are independent given no evidence?
A. a,b
B. c,d
C. e,d
D. c,e
Correct Answer : A. a,b
Detailed Solution : Nodes a and b don’t have any predecessor nodes. As they don’t
have any common parent nodes, a and b are independent.
______________________________________________________________________
QUESTION 4:
Consider the following Bayesian network. The random variables given in the model are
modeled as discrete variables (Rain = R, Sprinkler = S and Wet Grass = W) and the
corresponding probability values are given below. (Note: (¬ X) represents complement
of X)
P(R) = 0.1
P(S) = 0.2
P(W | R, S) = 0.8
P(W | R, ¬ S) = 0.7
P(W | ¬ R, S) = 0.6
P(W | ¬ R, ¬ S) = 0.5
A. 1
B. 0.5
C. 0.22
D. 0.78
𝑃(𝑊,𝑆,𝑅) 𝑃(𝑊𝑆𝑅)
Detailed Solution : 𝑃(𝑆|𝑊, 𝑅) = 𝑃(𝑊,𝑅) =
𝑃(𝑊𝑆𝑅)+𝑃(𝑊𝑆𝑅)
𝑃(𝑊𝑆𝑅) = 𝑃(𝑊|𝑆, 𝑅) * 𝑃(𝑅) * 𝑃(𝑆) = 0. 8 * 0. 1 * 0. 2 = 0. 016
𝑃(𝑊𝑆𝑅) = 𝑃(𝑊|𝑆, 𝑅) * 𝑃(𝑅) * 𝑃(𝑆) = 0. 7 * 0. 1 * 0. 8 = 0. 056
𝑃(𝑊,𝑆,𝑅) 𝑃(𝑊𝑆𝑅) 0.016
𝑃(𝑆|𝑊, 𝑅) = 𝑃(𝑊,𝑅)
= = 0.016+0.056
= 0. 22
𝑃(𝑊𝑆𝑅)+𝑃(𝑊𝑆𝑅)
______________________________________________________________________
QUESTION 5:
What is the naive assumption in a Naive Bayes Classifier?
Correct Answer: B. All the features of a class are independent of each other
Detailed Solution: Naive Bayes Assumption is that all the features of a class are
independent of each other.
______________________________________________________________________
QUESTION 6:
A drug test (random variable T) has 1% false positives (i.e., 1% of those not taking
drugs show positive in the test), and 5% false negatives (i.e., 5% of those taking drugs
test negative). Suppose that 2% of those tested are taking drugs. Determine the
probability that somebody who tests positive is actually taking drugs (random variable
D).
A. 0.66
B. 0.34
C. 0.50
D. 0.91
QUESTION 7:
It is given that 𝑃(𝐴|𝐵) = 2/3 and 𝑃(𝐴|𝐵) = 1/4. Compute the value of 𝑃(𝐵|𝐴).
A. ½
B. ⅔
C. ¾
D. Not enough information.
Correct Solution : D. Not enough information.
Detailed Solution : There are 3 unknown probabilities 𝑃(𝐴), 𝑃(𝐵), 𝑃(𝐴𝐵) which can not
be computed from the 2 given probabilities. So, we don’t have enough information to
compute 𝑃(𝐵|𝐴).
______________________________________________________________________
QUESTION 8:
Consider the following Bayesian network, where F = having the flu and C = coughing:
A. 0.35, 0.23
B. 0.35,0.77
C. 0.24, 0.024
D. 0.5, 0.23
Detailed Solution :
______________________________________________________________________
QUESTION 9:
Bag I contains 4 white and 6 black balls while another Bag II contains 4 white and 3
black balls. One ball is drawn at random from one of the bags and it is found to be
black. Find the probability that it was drawn from Bag I.
A. 1/2
B. 2/3
C. 7/12
D. 9/23
______________________________________________________________________
QUESTION 10:
In a Bayesian network a node with only outgoing edge(s) represents
Detailed Solution : As there is no incoming edge for the node, the node is not
conditionally dependent on any other node.
______________________________________________________________________
************END*******