Quiz Space

September 2022 term · Machine Learning Practice · BSCS2008

MLP End Term: 11 December 2022, Set ETD1-2 (September 2022 term)

The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 11 Dec 2022, in the September 2022 term, set ETD1-2: 38 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
38
Marks
100
Duration
180 min
MCQ
27
MSQ
6
Numerical
5

Updated

Official paper: IIT M DIPLOMA AN1 EXAM ETD1 11 Dec 2022 · No negative marking.

Question 1

+2 marksOne correct option

We wish to load digit dataset from sklearn. Which of the following will result into an error?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 2

+2 marksOne correct option

Which of the following statements is/are incorrect about the AUC?

  1. A

    AUC stands for Area Underneath the Curve.

  2. B

    A completely effective classifier is a diagonal line, and it will have an AUC of 0.5.

  3. C

    The larger the value of AUC, the more effective the classifier.

  4. D

    An AUC of 1 indicates a perfect classifier, which means it gets all the 1s correctly classified, and doesn’t misclassify any 0s as 1s.

  5. E

    None of these.

Show answer

Correct answer

  • B

    A completely effective classifier is a diagonal line, and it will have an AUC of 0.5.

Question 3

+2 marksOne correct option

Which of the following options represents the correct option to set the regularization rate in RidgeClassifier?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 4

+2 marksOne correct option

Putting loss=hinge in class sklearn.linear_model.SGDClassifier(loss=’hinge’) dictates which of the following loss functions in SGDClassifier?

  1. A

    hinge but quadratically penalized

  2. B

    logistic regression

  3. C

    linear SVM

  4. D

    None of these

Show answer

Correct answer

  • C

    linear SVM

Question 5

+2 marksOne correct option

Which of the following Naive Bayes algorithms can be applied if the data is imbalanced?

  1. A

    GaussianNB

  2. B

    ComplementNB

  3. C

    CategoricalNB

  4. D

    None of these

Show answer

Correct answer

  • B

    ComplementNB

Question 6

+2 marksOne correct option

Which of the following options represents the correct output for the following block of code?

  1. A

    [0.]

  2. B

    [0.5]

  3. C

    [1.5]

  4. D

    [1.]

Show answer

Correct answer

  • D

    [1.]

Question 7

+2 marksOne correct option

Mention which of the following statement(s) is / are correct?
1. Statement 1: Incremental learning is a dynamic technique which is applied when training data becomes available gradually over time or its size is out of system memory limits.
2. Statement 2: Sklearn can process large data in batches and updates the model parameters for each batch.

  1. A

    Statement 1 is correct but statement 2 is incorrect.

  2. B

    Statement 1 is incorrect but statement 2 is correct.

  3. C

    Statement 1 and statement 2 both are incorrect.

  4. D

    Statement 1 and statement 2 both are correct.

Show answer

Correct answer

  • D

    Statement 1 and statement 2 both are correct.

Question 8

+2 marksOne correct option

Which of the following options implements largest measure of regularization, i.e. which of these models will have lowest overfitting?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 9

+2 marksOne correct option

Consider the following scatter plots of four different input datasets:

Which data will be classified better using gaussian rbf kernel?

  1. A

    Data 4

  2. B

    Data 3

  3. C

    Data 1

  4. D

    Data 2

Show answer

Correct answer

  • C

    Data 1

Question 10

+2 marksOne correct option

Consider following statements regarding a decision tree model:
1. It is a non-parametric model.
2. It has a tendency to underfit if allowed to grow unconditionally.
3. It can be used for regression and classification problems only, but not for clustering. 4. It is one of the most difficult machine learning models to interpret.
5. For regression problems, decision tree’s loss function and evaluation metric can be same. Choose the option with all the correct statements:

  1. A

    1, 3, 5

  2. B

    1, 3

  3. C

    3, 5

  4. D

    2, 4

  5. E

    1, 3, 4

  6. F

    1, 2, 4

Show answer

Correct answer

  • A

    1, 3, 5

Question 11

+2 marksOne correct option

When a node is split in a decision tree (in sklearn):

  1. A

    It creates only two new children nodes always.

  2. B

    It can create two or more new children nodes always.

  3. C

    It depends on the cardinality of the categorical feature.

  4. D

    It depends on the scale of the numerical feature.

Show answer

Correct answer

  • A

    It creates only two new children nodes always.

Question 12

+2 marksOne correct option

Consider following statements:
1. The K-means algorithm aims to choose centroids that minimise the inertia.
2. The K-Means algorithm requires the number of clusters to be specified
Choose the correct option of the following:

  1. A

    Both statement 1 and 2 are correct.

  2. B

    Statement 1 is correct but statement 2 is incorrect.

  3. C

    Statement 1 is incorrect but statement 2 is correct.

  4. D

    Both statement 1 and 2 are incorrect.

Show answer

Correct answer

  • A

    Both statement 1 and 2 are correct.

Question 13

+2 marksOne correct option

Hierarchical Clustering can also be called as

  1. A

    Centroid Based Clustering

  2. B

    Distribution-based Clustering

  3. C

    Density-based Clustering

  4. D

    Connectivity-Based Clustering

Show answer

Correct answer

  • D

    Connectivity-Based Clustering

Question 14

+2 marksOne or more correct options

Which of the following options represents the major difference between HashingVectorizer and CountVectorizer?

Select all that apply.

  1. A

    HashingVectorizer does not store vocabulary, its object takes less space compared to CountVectorizer

  2. B

    CountVectorizer does not store vocabulary, its object takes less space compared to HashingVectorizer

  3. C

    HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning

  4. D

    CountVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning

Show answer

Correct answers

  • A

    HashingVectorizer does not store vocabulary, its object takes less space compared to CountVectorizer

  • C

    HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning

Question 15

+2 marksOne or more correct options

The partial_fit in sklearn’s Perceptron model helps to:

Select all that apply.

  1. A

    Iteratively train the model over a large dataset

  2. B

    Implement batch gradient descent

  3. C

    Update half of the weight parameters in each epoch.

  4. D

    Tracking progress of the model in each iteration.

Show answer

Correct answers

  • A

    Iteratively train the model over a large dataset

  • B

    Implement batch gradient descent

  • D

    Tracking progress of the model in each iteration.

Question 16

+2 marksOne or more correct options

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • A
  • B

Question 17

+2 marksOne or more correct options

Which of the following are hyper parameters in a decision tree in sklearn?

Select all that apply.

  1. A

    Number of features

  2. B

    Number of minimum samples to split

  3. C

    Height of the tree

  4. D

    Diameter of the tree

Show answer

Correct answers

  • B

    Number of minimum samples to split

  • C

    Height of the tree

Question 18

+2 marksNumerical answer

Enter the output (up to 2 decimal points) for the following block of code.

Show answer

Correct answer: 12 (accepted within ±0.05)

Question 19

+3 marksOne correct option

Consider the following code snippet:

  1. A

    array([[1., 2., 1., 4., 2., 1.], [1., 2., 1., 4., 2., 1.]])

  2. B

    array([[1., 2., 1., 4., 2., 1., 4., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 4., 4., 2., 1.]])

  3. C

    array([[1., 2., 1., 2.], [1., 2., 1., 2.]])

  4. D

    array([[1., 2., 1., 4., 2., 1., 8., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 8., 4., 2., 1.]])

Show answer

Correct answer

  • D

    array([[1., 2., 1., 4., 2., 1., 8., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 8., 4., 2., 1.]])

Question 20

+3 marksOne correct option

Which of the following is likely to be the correct output of the code given below?

  1. A

    [0.85,0.1,0.05]

  2. B

    [2,3,1]

  3. C

    [0.85,0]

  4. D

    There are some mistakes in the 3rd /4th line of code, hence it will produce error.

Show answer

Correct answer

  • C

    [0.85,0]

Question 21

+3 marksOne correct option

Which of the following is likely to be the correct output of the code given below?

  1. A

    5

  2. B

    99

  3. C

    Given code will produce an error

  4. D

    0.96

Show answer

Correct answer

  • C

    Given code will produce an error

Question 22

+3 marksOne correct option

The correct code block or blocks to set adaptive learning rate while using SGDRegressor will be:

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 23

+3 marksOne correct option

Consider following statements:
1. Statement 1 : In order to extend ROC curve and ROC area to multi-label classification, it is necessary to binarize the output.
2. Statement 2: In SGDClassifier, setting warm_start=True retains the weight values of the model after max_iter and hence produce different results for each execution.
Choose the correct option:

  1. A

    Statement 1 is correct but statement 2 is incorrect.

  2. B

    Statement 1 is incorrect but statement 2 is correct.

  3. C

    Statement 1 and statement 2 both are incorrect.

  4. D

    Statement 1 and statement 2 both are correct.

Show answer

Correct answer

  • D

    Statement 1 and statement 2 both are correct.

Question 24

+3 marksOne correct option

Which of the following options represents the correct output for the following block of code?

  1. A

    (11, 1)

  2. B

    (1, 11)

  3. C

    (10, 1)

  4. D

    (1, 10)

Show answer

Correct answer

  • D

    (1, 10)

Question 25

+3 marksOne correct option

Which of the following options represents the correct output for the following block of code?

  1. A

    array([’is’, ’sparta’, ’this’], dtype=object)

  2. B

    array([’is’, ’sparta’, ’this’,’ !’], dtype=object)

  3. C

    array([ ’sparta’, ’this’,’ !’], dtype=object)

  4. D

    array([’sparta’], dtype=object)

Show answer

Correct answer

  • A

    array([’is’, ’sparta’, ’this’], dtype=object)

Question 26

+3 marksOne correct option

Which of the following options represents the correct output of the following block of code?

  1. A

    array([2])

  2. B

    array([1.5])

  3. C

    array([1])

  4. D

    array([0])

Show answer

Correct answer

  • C

    array([1])

Question 27

+3 marksOne correct option

You have a regression problem to solve with following information:
1. All features are numerical.
2. The dataset has size of 40 GB.
3. The data has to be preprocessed.
4. After data preprocessing, train the model with gradient descent or its variations.
Which of the following will perform the above task?

  1. A

    Perform one hot encoding followed by training with LinearRegression model (from sklearn.linear_model).

  2. B

    Perform standard scaling followed by training with KNeighborsRegressor model (from sklearn.neighbors).

  3. C

    Perform min-max scaling followed by training with DecisionTreeRegressor model (from sklearn.tree).

  4. D

    Perform min-max scaling followed by training with SGDRegressor model (from sklearn.linear_model).

Show answer

Correct answer

  • D

    Perform min-max scaling followed by training with SGDRegressor model (from sklearn.linear_model).

Question 28

+3 marksOne or more correct options

Consider the following code and select the correct options.
(Note: Assume necessary imports.)

Select all that apply.

  1. A

    Scaled data have values in between [0, 1].

  2. B

    Regressor has three hidden layers.

  3. C

    Regressor has 150 hidden layers.

  4. D

    Regressor applies stochastic gradient decent to update the weights.

Show answer

Correct answers

  • B

    Regressor has three hidden layers.

  • D

    Regressor applies stochastic gradient decent to update the weights.

Question 29

+3 marksNumerical answer

Refer the dataframe(df) given below and enter the correct output (up to 2 decimal points) for the following block of code:

NameAssignment-1Assignment-2Assignment-3
0tom528478
1nick517681
2juli417681
3Abhi626782
4Krish517284

Figure 2: Sample dataframe

python
import pandas as pd
import numpy as np
df['total'] = df['Assignment-1']+df['Assignment-2']+df['Assignment-3']
print(df['total'].max()-df["total"].min())
Show answer

Correct answer: 16 (accepted within ±0.05)

Question 30

+3 marksNumerical answer

The output of the following block of code will be:

Show answer

Correct answer: 6

Question 31

+3 marksNumerical answer

Enter the output (up to 2 decimal points) for the following block of code.

Show answer

Correct answer: 0.75

Question 32

+3 marksNumerical answer

What is the correct output of the following block of code?
[Note: LinearSVC implements “one-vs-the-rest” multi-class strategy]

Show answer

Correct answer: 3

Question 33

+4 marksOne correct option

Which of the following options represents all the correct precision, Recall, and accuracy values for the confusion matrix shown in Figure 1?
[Note: All 3 values should be correct in the same option]

  1. A

    Precision: 0.9783, Recall: 0.9289, Accuracy: 0.9909

  2. B

    Precision: 0.9289, Recall: 0.9783, Accuracy: 0.9909

  3. C

    Precision: 0.9909, Recall: 0.9783, Accuracy: 0.9289

  4. D

    None of these.

Show answer

Correct answer

  • A

    Precision: 0.9783, Recall: 0.9289, Accuracy: 0.9909

Question 34

+4 marksOne correct option

Which of the following options represents the correct output of the following block of code?

  1. A

    1

  2. B

    0

  3. C

    0.210

  4. D

    0.105

  5. E

    0.233

Show answer

Correct answer

  • D

    0.105

Question 35

+4 marksOne correct option

Rajesh wants to tune hyper parameters of an AdaBoost model for a classification problem with following specifications:
1. Base estimator as Decision trees classifier with max_depth=1.
2. Number of estimators range from 10 to 20 (both inclusive) at the interval of 1.
3. Cross validation =4.
4. Learning rate must vary between 0.1 to 1.0 (both inclusive) at the intervals of 0.1.
5. Train the best model on the entire training set.
6. Print score on test set.
Which of the following code blocks will correctly execute Rajesh’s task?
[Note: Assume necessary imports and variables for training and test sets.]

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answer

  • A

Question 36

+4 marksOne correct option

Asha wants to train a bagging classifier with following specifications:
1. Base estimator as k nearest neighbour classifier with default parameter values.
2. 70% of the data is used to create a bag of samples.
3. Create subsets of training set with replacement.
4. Take all features when bootstrapping.
5. Train the model on training set.
6. Print score on test set.
Which of the following code blocks will correctly execute Asha’s task?
[Note: Assume necessary imports and variables for training and test sets.]

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answer

  • A

Question 37

+3 marksOne or more correct options

Go through the code snippet given below and answer the given subquestions.

python
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import RidgeCV
from sklearn.datasets import load_diabetes
dataset = load_diabetes(as_frame=True)
X=dataset.data
y=dataset.target
lf= np.arange(0.01, 1, 0.03)
ridge_reg_pipeline = Pipeline([("poly", PolynomialFeatures(degree=2)),
("feature_scaling", StandardScaler())
])
ridge= RidgeCV(alphas=lf,scoring="neg_mean_squared_error")
results = ridge.fit(X,y)

Based on the given code, select all option which will be considered as input alpha value for our RidgeCV estimator.

Select all that apply.

  1. A

    0.03

  2. B

    0.7

  3. C

    0.01

  4. D

    0.1

  5. E

    1

Show answer

Correct answers

  • B

    0.7

  • C

    0.01

  • D

    0.1

Question 38

+3 marksOne correct option

Go through the code snippet given below and answer the given subquestions.

python
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import RidgeCV
from sklearn.datasets import load_diabetes
dataset = load_diabetes(as_frame=True)
X=dataset.data
y=dataset.target
lf= np.arange(0.01, 1, 0.03)
ridge_reg_pipeline = Pipeline([("poly", PolynomialFeatures(degree=2)),
("feature_scaling", StandardScaler())
])
ridge= RidgeCV(alphas=lf,scoring="neg_mean_squared_error")
results = ridge.fit(X,y)

Which of the following could be the possible output of print(results.best_score_)?

  1. A

    1

  2. B

    -3000.38

  3. C

    0.528

  4. D

    0.681

Show answer

Correct answer

  • B

    -3000.38