0% found this document useful (0 votes)
197 views26 pages

ML Assignment 3 Nptel 2019

ML ASSIGNMENT Solutions

Uploaded by

Ashok Kumar
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)
197 views26 pages

ML Assignment 3 Nptel 2019

ML ASSIGNMENT Solutions

Uploaded by

Ashok Kumar
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/ 26

NPTEL Online Certification Courses Indian

Institute of Technology Kharagpur

Introduction to
Machine Learning
Assignment- Week 3
TYPE OF QUESTION: MCQ
Number of questions: 8 Total mark: 8 X 2 = 16

QUESTION 1:

Suppose, you have given the following data where x and y are the 2 input variables and Class is
the dependent variable.

X Y Class

-1 1 -

0 1 +

0 2 -

1 -1 -

1 0 +

1 2 +

2 2 -

2 3 +

Suppose, you want to predict the class of new data point x=1 and y=1 using euclidean distance in
7-NN. To which class the data point belongs to?
A. + Class
B. – Class
C. Can’t say
D. None of these

Correct Answer: B. – Class


Detailed Solution : We have to compute the euclidean distance from the given point (1,1) to all
the data points given in the dataset and based on that we have to check the dominating class for
the 7 nearest points.
NPTEL Online
Certification Courses
Indian Institute of
Technology
Kharagpur

______________________________________________________________________________

QUESTION 2:

Imagine you are dealing with 15 class classification problem. What is the maximum number of
discriminant vectors that can be produced by LDA?
A. 20
B. 14
C. 21
D. 10
Correct Answer: B. 14
Detailed Solution : LDA produces at most c − 1 discriminant vectors, c = no of classes

______________________________________________________________________________

QUESTION 3:

‘People who bought this, also bought…’ recommendations seen on amazon is a result of which
algorithm?

A. User based Collaborative filtering


B. Content based filtering
C. Item based Collaborative filtering
D. None of the above

Correct Answer: C. Item based Collaborative filtering

Detailed Solution : Though both User based and Item based CF methods are used in
recommendation systems, Amazon specifically uses Item based filtering.

______________________________________________________________________________
NPTEL Online Certification Courses Indian
Institute of Technology Kharagpur

QUESTION 4:

Which of the following is/are true about PCA?

1. PCA is a supervised method


2. It identifies the directions that data have the largest variance
3. Maximum number of principal components <= number of features
4. All principal components are orthogonal to each other

A. Only 2
B. 1, 3 and 4
C. 1, 2 and 3
D. 2, 3 and 4

Correct Answer: D

Detailed Solution : PCA is an unsupervised learning algorithm, so 1 is wrong. Other options are
true about PCA.

______________________________________________________________________________

QUESTION 5:

Consider the figures below. Which figure shows the most probable PCA component directions for
the data points?
A. A
B. B
C. C
D. D

Correct Answer: A. A

Detailed Solution : PCA tries to choose the direction in such a way that maximizes the variance in the
data.
______________________________________________________________________________

QUESTION 6:

When there is noise in data, which of the following options would improve the performance of the KNN
algorithm?

A. Increase the value of k


B. Decrease the value of k
C. Changing value of k will not change the effect of the noise
D. None of these

Correct Answer: A. Increase the value of k

Detailed Solution : Increasing the value of k reduces the effect of the noise and improves the
performance of the algorithm.
______________________________________________________________________________
QUESTION 7:

Which of the following statements is True about the KNN algorithm?

A. KNN algorithm does more computation on test time rather than train time.
B. KNN algorithm does lesser computation on test time rather than train time.
C. KNN algorithm does an equal amount of computation on test time and train time.
D. None of these.

Correct Answer: A. KNN algorithm does more computation on test time rather than train
time.

Detailed Solution : The training phase of the algorithm consists only of storing the feature
vectors and class labels of the training samples.
In the testing phase, a test point is classified by assigning the label which are most frequent
among the k training samples nearest to that query point – hence higher computation.
______________________________________________________________________________

QUESTION 8:
Find the value of the Pearson’s correlation coefficient of X and Y from the data in the following
table.

AGE (X) GLUCOSE (Y)

43 99

21 65

25 79

42 75

A. 0.47
B. 0.68
C. 1
D. 0.33
Correct Answer : B. 0.68

∑(𝑋𝑖−𝑋)((𝑌𝑖−𝑌)
Detailed Solution : Pearson Coefficient 𝑟 = 𝑖

2 2
∑(𝑋𝑖−𝑋) ∑(𝑌𝑖−𝑌)
𝑖 𝑖

______________________________________________________________________________

******END*****
NPTEL Online Certification Courses Indian
Institute of Technology Kharagpur

Introduction to
Machine Learning
Assignment- Week 3
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 X 2 = 20

QUESTION 1:

Suppose, you have given the following data where x and y are the 2 input variables and Class is
the dependent variable.

X Y Class

-1 1 -

0 1 +

0 2 -

1 -1 -

1 0 +

1 2 +

2 2 -

2 3 +

Suppose, you want to predict the class of new data point x=1 and y=1 using euclidean distance in
3-NN. To which class the new data point belongs to?
A. + Class
B. – Class
C. Can’t say
D. None of these

Correct Answer: A. + Class

Detailed Solution : We have to compute the euclidean distance from the given point (1,1) to all
the data points given in the dataset and based on that we have to check the dominating class for
the 3 nearest points.
NPTEL Online
Certification Courses
Indian Institute of
Technology
Kharagpur

______________________________________________________________________________

QUESTION 2:

Imagine you are dealing with a 10 class classification problem. What is the maximum number of
discriminant vectors that can be produced by LDA?
A. 20
B. 14
C. 9
D. 10
Correct Answer: C. 9
Detailed Solution : LDA produces at most c − 1 discriminant vectors, c = no of classes

______________________________________________________________________________

QUESTION 3:

Fill in the blanks:


K-Nearest Neighbor is a _____ , _____ algorithm
A. Non-parametric, eager
B. Parametric, eager
C. Non-parametric, lazy
D. Parametric, lazy

Correct Answer: C. Non-parametric, lazy

Detailed Solution: KNN is non-parametric because it does not make any assumption regarding the
underlying data distribution. It is a lazy learning technique because during training time it just
memorizes the data and finally computes the distance during testing.

______________________________________________________________________________
NPTEL Online Certification Courses Indian
Institute of Technology Kharagpur

QUESTION 4:

Which of the following statements is True about the KNN algorithm?

A. KNN algorithm does more computation on test time rather than train time.
B. KNN algorithm does lesser computation on test time rather than train time.
C. KNN algorithm does an equal amount of computation on test time and train time.
D. None of these.

Correct Answer: A. KNN algorithm does more computation on test time rather than train
time.

Detailed Solution : The training phase of the algorithm consists only of storing the feature
vectors and class labels of the training samples.
In the testing phase, a test point is classified by assigning the label which is the most frequent
among the k training samples nearest to that query point – hence higher computation.

______________________________________________________________________________

QUESTION 5:
Which of the following necessitates feature reduction in machine learning?
A. Irrelevant and redundant features
B. Curse of dimensionality
C. Limited computational resources.
D. All of the above
Correct Answer: D. All of the above

Detailed Solution: All these things necessitate feature reduction.


______________________________________________________________________________
QUESTION 6:

When there is noise in data, which of the following options would improve the performance of the
KNN algorithm?

A. Increase the value of k


B. Decrease the value of k
C. Changing value of k will not change the effect of the noise
D. None of these

Correct Answer: A. Increase the value of k

Detailed Solution : Increasing the value of k reduces the effect of the noise and improves
the performance of the algorithm.
____________________________________________________________________________

QUESTION 7:
Find the value of the Pearson’s correlation coefficient of X and Y from the data in the following
table.

AGE (X) GLUCOSE (Y)

43 99

21 65

25 79

42 75

A. 0.47
B. 0.68
C. 1
D. 0.33
Correct Answer : B. 0.68

∑(𝑋𝑖−𝑋)((𝑌𝑖−𝑌)
Detailed Solution : Pearson Coefficient 𝑟 = 𝑖

2 2
∑(𝑋𝑖−𝑋) ∑(𝑌𝑖−𝑌)
𝑖 𝑖

______________________________________________________________________________

QUESTION 8:

Which of the following is false about PCA?

A. PCA is a supervised method


B. It identifies the directions that data have the largest variance
C. Maximum number of principal components <= number of features
D. All principal components are orthogonal to each other

Correct Answer : A. PCA is a supervised method

Detailed Solution : PCA is an unsupervised learning algorithm.

______________________________________________________________________________
QUESTION 9:
In user-based collaborative filtering based recommendation, the items are recommended
based on :
A. Similar users
B. Similar items
C. Both of the above
D. None of the above

Correct Answer: A. Similar users

Detailed Solution: In User-based CF, items are recommended based on similar users.

______________________________________________________________________________

QUESTION 10:
Identify whether the following statement is true or false?
“PCA can be used for projecting and visualizing data in lower dimensions.”

A. TRUE
B. FALSE

Correct Answer : A. TRUE

Detailed Solution : Sometimes it is very useful to plot the data in lower dimensions. We
can take the first 2 principal components and then visualize the data.

______________________________________________________________________________
******END*****
Introduction to Machine Learning -IITKGP
Assignment - 3
TYPE OF QUESTION: MCQ/MSQ
Number of questions: 15 Total mark: 2 * 15 = 30

Q1. Fill in the blanks:

K-Nearest Neighbor is a _____, _____ algorithm

a. Non-parametric, eager

b. Parametric, eager

c. Non-parametric, lazy

d. Parametric, lazy

Correct Answer: c

Explanation: KNN is non-parametric because it does not make any assumption regarding the
underlying data distribution. It is a lazy learning technique because during training time it just
memorizes the data and finally computes the distance during testing.

Q2. You have been given the following 2 statements. Find out which of these options is/are
true in the case of k-NN.
(i) In case of very large value of k, we may include points from other classes into the
neighborhood.
(ii) In case of too small value of k, the algorithm is very sensitive to noise.

a. (i) is True and (ii) is False


b. (i) is False and (ii) is True
c. Both are True
d. Both are False

Correct Answer: c

Explanation: Both options are true and are self-explanatory.


Q3. State whether the statement is True/False:
k-NN algorithm does more computation on test time rather than train time.

a. True
b. False

Correct Answer: a

Explanation: The training phase of the algorithm consists only of storing the feature vectors
and class labels of the training samples.

In the testing phase, a test point is classified by assigning the label which is most frequent
among the k training samples nearest to that query point – hence higher computation.

Q4. Suppose you are given the following images (1 represents the left image, 2 represents
the middle and 3 represents the right). Now your task is to find out the value of k in k-NN in
each of the images shown below. Here k1 is for 1st, k2 is for 2nd and k3 is for 3rd figure.

a. k1 > k2> k3
b. k1 < k2> k3
c. k1 < k2 < k3
d. None of these

Correct Answer: c

Explanation: The value of k is highest in k3, whereas in k1 it is lowest. As the decision


boundary is more smooth in the right image than the others.
Q5. Which of the following necessitates feature reduction in machine learning?
a. Irrelevant and redundant features
b. Limited training data
c. Limited computational resources.
d. All of the above
Correct Answer: d

Detailed Solution: Follow lecture slides

Q6. Suppose, you have given the following data where x and y are the 2 input variables and
Class is the dependent variable.

Below is a scatter plot which shows the above data in 2D space.


Suppose, you want to predict the class of new data point x=1 and y=1 using Euclidean
distance in 3-NN. In which class this data point belongs to?

a. + Class
b. – Class
c. Can’t Say
d. None of these

Correct Answer: a

Explanation: All three nearest point are of + class so this point will be classified as + class.

Q7. What is the optimum number of principal components in the below figure?

a. 10
b. 20
c. 30
d. 40

Correct Answer: c

Explanation: We can see in the above figure that the number of components = 30 is giving
highest variance with lowest number of components. Hence option ‘c’ is the right answer.
Q8. Suppose we are using dimensionality reduction as pre-processing technique, i.e, instead
of using all the features, we reduce the data to k dimensions with PCA. And then use these
PCA projections as our features. Which of the following statements is correct?

Choose which of the options is correct?

a. Higher value of ‘k’ means more regularization


b. Higher value of ‘k’ means less regularization

Correct Answer: b

Explanation: The higher value of ‘k’ would lead to less smoothening of the decision boundary.
This would be able to preserve more characteristics in data, hence less regularization.

Q9. In collaborative filtering-based recommendation, the items are recommended based on


:
a. Similar users
b. Similar items
c. Both of the above
d. None of the above

Correct Answer: a

Explanation: Follow the definition of collaborative filtering.

Q10. The major limitation of collaborative filtering is:

a. Cold start
b. Overspecialization
c. None of the above

Correct Answer: a

Explanation: For new users, we have very few transactions. So, it’s very difficult to find similar
users.
Q11. Consider the figures below. Which figure shows the most probable PCA component
directions for the data points?

a. A
b. B
c. C
d. D

Correct Answer: a
Explanation: [Follow the lecture slides]
Choose directions such that a total variance of data will be maximum
1. Maximize Total Variance
Choose directions that are orthogonal
2. Minimize correlation
Q12. Suppose that you wish to reduce the number of dimensions of a given data to dimensions
using PCA. Which of the following statement is correct?

a. Higher means more regularization


b. Higher means less regularization
c. Can’t Say

Correct Answer: b

Explanation: Higher k value leads to less smoothening as we preserve more characteristics in


data, hence less regularization.

Q13. Suppose you are given 7 plots 1-7 (left to right) and you want to compare Pearson
correlation coefficients between variables of each plot. Which of the following is true?

1. 1<2<3<4
2. 1>2>3>4
3. 7<6<5<4
4. 7>6>5>4

a. 1 and 3
b. 2 and 3
c. 1 and 4
d. 2 and 4

Correct Answer: b

Explanation: From image 1 to 4, correlation is decreasing (coefficient values are positive).


From image 4 to 7 correlation is increasing, but the coefficient values are negative (for
example, 0, -0.3, -0.7, -0.99).
Q14. Imagine you are dealing with 20 class classification problem. What is the maximum
number of discriminant vectors that can be produced by LDA?
a. 20
b. 19
c. 21
d. 10

Correct Answer: b
Explanation: LDA produces at most c − 1 discriminant vectors.

Q15. In which of the following situations collaborative filtering algorithm is appropriate?


a. You manage an online bookstore and you have the book ratings from many users. For
each user, you want to recommend other books he/she will like based on her previous
ratings and other users’ ratings.
b. You manage an online bookstore and you have the book ratings from many users. You
want to predict the expected sales volume (No of books sold) as a function of average rating
of a book.
c. Both A and B
d. None of the above

Correct Answer: a

Explanation: Collaborative filtering is a recommendation technique that is specifically


designed for situations like the one described in option a. In collaborative filtering,
recommendations are made based on the patterns of user preferences and behaviors. It
analyzes the historical data of user-item interactions, such as book ratings given by users, to
find similarities between users and items.

Option b is not appropriate for collaborative filtering because it involves predicting the
expected sales volume (number of books sold) as a function of average rating of a book.
Collaborative filtering focuses on user-item interactions and is more concerned with providing
personalized recommendations rather than predicting sales volume based on average ratings.

************END************
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Introduction to
Machine Learning
Assignment- Week 3
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 X 2 = 20

QUESTION 1:

Suppose, you have been given the following data where x1 and x2 are the 2 input
variables and Class is the dependent variable.

x1 x2 Class

-1 1 -

0 1 +

0 2 -

1 -1 -

1 0 +

1 2 +

2 2 -

2 3 +

What will be the class of a new data point x1=1 and x2=1 in 5-NN (k nearest neighbour
with k=5) using euclidean distance measure?
A. + Class
B. – Class
C. Cannot be determined

Correct Answer: A. + Class


Detailed Solution : 5 nearest points to the new point (1,1) are: (0,1), (0,2), (1,0), (1,2),
(2,2). The majority class among these 5 nearest neighbours is + Class.
_______________________________________________________________________

QUESTION 2:

Imagine you are dealing with a 10 class classification problem. What is the maximum
number of discriminant vectors that can be produced by LDA?
A. 20
B. 14
C. 9
D. 10
Correct Answer: C. 9
Detailed Solution : LDA produces at most c − 1 discriminant vectors, c = no of classes

_______________________________________________________________________

QUESTION 3:

Fill in the blanks:


K-Nearest Neighbor is a _____ , _____ algorithm
A. Non-parametric, eager
B. Parametric, eager
C. Non-parametric, lazy
D. Parametric, lazy

Correct Answer: C. Non-parametric, lazy

Detailed Solution: KNN is non-parametric because it does not make any


assumption regarding the underlying data distribution. It is a lazy learning
technique because during training time it just memorizes the data and finally
computes the distance during testing.

_______________________________________________________________________
NPTEL Online Certification Courses Indian
Institute of Technology Kharagpur

QUESTION 4:

Which of the following statements is True about the KNN algorithm?

A. KNN algorithm does more computation on test time rather than train time.
B. KNN algorithm does lesser computation on test time rather than train time.
C. KNN algorithm does an equal amount of computation on test time and train time.
D. None of these.

Correct Answer: A. KNN algorithm does more computation on test time rather than
train time.

Detailed Solution : The training phase of the algorithm consists only of storing the feature
vectors and class labels of the training samples.
In the testing phase, a test point is classified by assigning the label which is the most
frequent among the k training samples nearest to that query point – hence higher
computation.
_______________________________________________________________________

QUESTION 5:
Which of the following necessitates feature reduction in machine learning?
1. Irrelevant and redundant features
2. Curse of dimensionality
3. Limited computational resources.

A. 1 only
B. 2 only
C. 1 and 2 only
D. 1, 2 and 3
Correct Answer: D. 1,2 and 3

Detailed Solution: All these things necessitate feature reduction.


_______________________________________________________________________
QUESTION 6:

When there is noise in data, which of the following options would improve the performance
of the k-NN algorithm?

A. Increase the value of k


B. Decrease the value of k
C. Changing value of k will not change the effect of the noise
D. None of these

Correct Answer: A. Increase the value of k

Detailed Solution : Increasing the value of k reduces the effect of the noise and
improves the performance of the algorithm.
_______________________________________________________________________

QUESTION 7:
Find the value of the Pearson’s correlation coefficient of X and Y from the data in the
following table.
AGE (X) GLUCOSE (Y)
43 99
21 65

25 79

42 75

A. 0.47
B. 0.68
C. 1
D. 0.33
Correct Answer : B. 0.68

∑(𝑋𝑖−𝑋)((𝑌𝑖−𝑌)
Detailed Solution : Pearson Coefficient 𝑟 = 𝑖

2 2
∑(𝑋𝑖−𝑋) ∑(𝑌𝑖−𝑌)
𝑖 𝑖
Where X = [43,21,25,42], Y = [99,65,79,75], 𝑋 = mean of 𝑋𝑖 values and 𝑌 = mean of

𝑌𝑖 values.

_______________________________________________________________________

QUESTION 8:

Which of the following statements is/are true about PCA?

1. PCA is a supervised method


2. It identifies the directions that data have the largest variance
3. Maximum number of principal components <= number of features
4. All principal components are orthogonal to each other

A. Only 2
B. 1, 3 and 4
C. 1, 2 and 3
D. 2, 3 and 4

Correct Answer: D
Detailed Solution : PCA is an unsupervised learning algorithm, so 1 is wrong. Other
statements are true about PCA.
_______________________________________________________________________

QUESTION 9:
In user-based collaborative filtering based recommendation, the items are
recommended based on :
A. Similar users
B. Similar items
C. Both of the above
D. None of the above

Correct Answer: A. Similar users

Detailed Solution: In User-based Collaborative filtering, items are recommended


based on similar users.

______________________________________________________________________
QUESTION 10:
Identify whether the following statement is true or false?
“Linear Discriminant Analysis (LDA) is a supervised method”

A. TRUE
B. FALSE

Correct Answer : A. TRUE

Detailed Solution : LDA is a supervised method as it makes use of the class


labels.

_______________________________________________________________________
******END****

You might also like