Quiz Space

January 2023 term · Machine Learning Practice · BSCS2008

MLP End Term: 30 April 2023, Set QPD1-S2 (January 2023 term)

The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 30 Apr 2023, in the January 2023 term, set QPD1-S2: 36 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
36
Marks
100
Duration
180 min
MCQ
26
MSQ
9
Numerical
1

Updated

Official paper: IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023 · No negative marking.

Question 1

+2 marksOne correct option

______________ generates a bunch of normally-distributed clusters of points with specific mean and standard deviations for each cluster.

  1. A

    sklearn.datasets.make_clusters()

  2. B

    sklearn.datasets.make_centers()

  3. C

    sklearn.datasets.make_normal_clusters()

  4. D

    sklearn.datasets.make_blobs()

Show answer

Correct answer

  • D

    sklearn.datasets.make_blobs()

Question 2

+2 marksOne correct option

Why is data preprocessing necessary?

  1. A

    Some columns have values only between 0 and 1

  2. B

    The data is divided into multiple types of files i.e. html, csv, tsv, etc.

  3. C

    The data has only numbers in all the columns.

Show answer

Correct answer

  • B

    The data is divided into multiple types of files i.e. html, csv, tsv, etc.

Question 3

+2 marksOne correct option

Which of the following is correct with respect to R2-score?

  1. A

    R2 score is always positive and it may go up to infinity.

  2. B

    R2 score is always positive, but it ranges between 0 and 1 only.

  3. C

    R2 score can be negative. That happens if our model is worse than the mean model.

  4. D

    R2 score can be negative. That happens if the mean model is worse than our model.

Show answer

Correct answer

  • C

    R2 score can be negative. That happens if our model is worse than the mean model.

Question 4

+2 marksOne correct option

Which options represent the output of the following code block?

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

Correct answer

  • C

Question 5

+2 marksOne correct option

Consider the following code block:

python
from sklearn.datasets import make_regression
X, y = make_regression(n_samples = 10, n_features = 3)
from sklearn.model_selection import LeavePOut
lpo = LeavePOut(p = 2)
count = 0
for train, test in lpo.split(X):
print(train, test)
count += 1
print(count)

What will be the value of the ‘count’?

  1. A

    20

  2. B

    30

  3. C

    45

  4. D

    15

Show answer

Correct answer

  • C

    45

Question 6

+2 marksOne correct option

Consider the following code block:

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

Correct answer

  • C

Question 7

+2 marksOne correct option

Which of the following is a hyperparameter?

  1. A

    L1-ratio in elasticnet

  2. B

    Pruning parameter in a decision tree

  3. C

    Learning rate in SGDRegressor

  4. D

    All of these

Show answer

Correct answer

  • D

    All of these

Question 8

+2 marksOne correct option
  1. A

    DecisionTreeClassifier

  2. B

    RandomForestRegressor

  3. C

    LogisticRegressor

  4. D

    SGDRegressor

Show answer

Correct answer

  • D

    SGDRegressor

Question 9

+2 marksOne correct option

Consider the following code

python
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
pipe = ([
('scaler', StandardScaler()),
('softmax', ____________ )
])

Which of the following options is True for blank space if I want to train the above pipeline as softmax regression ?

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

Correct answer

  • D

Question 10

+2 marksOne correct option

Consider the following code:

  1. A

    0.66

  2. B

    0.72

  3. C

    0.80

  4. D

    1.00

Show answer

Correct answer

  • B

    0.72

Question 11

+2 marksOne correct option

Which of the following are correct about sklearn.svm.SVC:

  1. A

    It will print number of support vectors

  2. B

    It will print an array of support vectors

  3. C

    It will print an array of probabilities representing distance from decision boundary with each data point.

  4. D

    It will print indices of the support vectors from the training set.

Show answer

Correct answer

  • B

    It will print an array of support vectors

Question 12

+2 marksOne correct option
  1. A

    It will print nearest neighbours from the test point

  2. B

    It will print indices of and distances to the neighbouring points (in training set) from test point

  3. C

    It will print indices, distance and nearest training point from the test point

  4. D

    It will throw an error

Show answer

Correct answer

  • B

    It will print indices of and distances to the neighbouring points (in training set) from test point

Question 13

+3 marksOne correct option

Which of the following APIs only supports conjoining transformers and estimators in series (i.e. one after another)?

  1. A

    Pipeline

  2. B

    ColumnTransformer

  3. C

    FeatureUnion

  4. D

    All of these

Show answer

Correct answer

  • A

    Pipeline

Question 14

+3 marksOne correct option

Consider the following ML task/steps for a regression dataset:
1. Read the data from a file (named ‘dataset.csv’). It has 7 columns. The last column is the target variable, all 6 features numerical.
2. Remove rows which have target values missing.
3. Fill the missing values in the features by KNN using 3 nearest neighbours.
4. Split the data into training and test sets. Take randomly the 70% of rows in the training set and the rest of them into the test set.
5. Train a simple linear regression model, with intercept, on the training set.
6. Report R2 score on the test set.
Which of the following code snippets correctly accomplishes the above task? Assume necessary imports.

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

Correct answer

  • A

Question 15

+3 marksOne correct option
  1. A

    (10, 3)

  2. B

    (10, 7)

  3. C

    (10, 8)

  4. D

    (10, 10)

  5. E

    (10, 11)

Show answer

Correct answer

  • B

    (10, 7)

Question 16

+3 marksOne correct option

Consider the following statements about SGDClassifier:
1. It can be used to train a model on large dataset that doesn’t fit in main memory
2. It can emulate a KNN model
3. It can emulate a decision tree model
4. It can emulate a perceptron
Choose the correction option(s)

  1. A

    1 and 4

  2. B

    1 and 2

  3. C

    2 and 3

  4. D

    3 and 4

Show answer

Correct answer

  • A

    1 and 4

Question 17

+3 marksOne correct option

Consider an image classification task: an image can have dogs, birds and trees. An image can have any combination of these three. The classifier is expected to report all these three for every sample. What kind of classification problem is this?

  1. A

    multi-label and multiclass problem.

  2. B

    multi-label and binary class problem.

  3. C

    multiclass problem.

  4. D

    binary class single label problem.

Show answer

Correct answer

  • A

    multi-label and multiclass problem.

Question 18

+3 marksOne correct option

Consider following code snippets, assuming necessary imports.

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

Correct answer

  • A

Question 19

+3 marksOne correct option

Which of the following options is true for the gamma parameter in a non-linear soft margin SVM?

  1. A

    For high values of gamma, the points need to be very close to each other in order to be considered in the same class

  2. B

    For low values of gamma, the points need to be very close to each other in order to be considered in the same class

  3. C

    Gamma doesn’t affect the SVM model at all

  4. D

    None of these

Show answer

Correct answer

  • A

    For high values of gamma, the points need to be very close to each other in order to be considered in the same class

Question 20

+3 marksOne correct option

Consider the following code:

python
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_wine
X,y = load_wine(as_frame = True, return_X_y = True)
dtc1 = DecisionTreeClassifier(ccp_alpha = 0.0)
dtc1.fit(X, y)
dtc2 = DecisionTreeClassifier(ccp_alpha = 0.06)
dtc2.fit(X, y)
dtc3 = DecisionTreeClassifier(ccp_alpha = 0.1)
dtc3.fit(X, y)
dtc4 = DecisionTreeClassifier(ccp_alpha = 0.03)
dtc4.fit(X, y)

Which model is likely to overfit the most?

  1. A

    dtc1

  2. B

    dtc2

  3. C

    dtc3

  4. D

    dtc4

Show answer

Correct answer

  • A

    dtc1

Question 21

+3 marksOne correct option

Following is the code to tune the n_estimators parameter of a Bagging Classifier model.

python
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import BaggingClassifier
param_grid = [
{______________: [200, 300, 400, 500, 600]}
]
pipeline = Pipeline(steps=[('scaler', StandardScaler()),
('bc', BaggingClassifier())])
grid_search = GridSearchCV(pipeline, param_grid, cv=5,
scoring='neg_mean_squared_error',
return_train_score=True)
grid_search.fit(X_train, y_train)

What should the blank space contain?

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

Correct answer

  • C

Question 22

+4 marksOne correct option

Consider the following code. How many DecisionTreeClassifier models will be trained internally?

  1. A

    20

  2. B

    200

  3. C

    8

  4. D

    150

  5. E

    15

  6. F

    80

Show answer

Correct answer

  • F

    80

Question 23

+4 marksOne correct option

Consider two classifiers as shown in the following block of code:

python
from sklearn.datasets import load_wine
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
X,y = load_wine(as_frame = True,
return_X_y = True)
X_train,X_test,y_train,y_test = train_test_split(X,
y,
test_size = 0.2,
random_state = 1)
clf1 = DecisionTreeClassifier(min_samples_split = 3, min_samples_leaf = 2,
random_state = 5)
clf1.fit(X_train, y_train)
clf2 = DecisionTreeClassifier(min_samples_split = 6, min_samples_leaf = 4,
random_state = 5)
clf2.fit(X_train, y_train)

What can we say about the depths of the classifiers clf1 and clf2?

  1. A

    depth(clf1) ≥ depth(clf2)

  2. B

    depth(clf1) ≤ depth(clf2)

  3. C

    depth(clf1) = depth(clf2)

  4. D

    Insufficient Information

Show answer

Correct answer

  • A

    depth(clf1) ≥ depth(clf2)

Question 24

+4 marksOne correct option

Consider the following code:

python
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_wine
X,y = load_wine(as_frame = True, return_X_y = True)
dtc1 = DecisionTreeClassifier(ccp_alpha = 0.0)
dtc1.fit(X, y)
dtc2 = DecisionTreeClassifier(ccp_alpha = 0.03)
dtc2.fit(X, y)
dtc3 = DecisionTreeClassifier(ccp_alpha = 0.06)
dtc3.fit(X, y)
dtc4 = DecisionTreeClassifier(ccp_alpha = 0.1)
dtc4.fit(X, y)
d1 = dtc1.get_depth()
d2 = dtc2.get_depth()
d3 = dtc3.get_depth()
d4 = dtc4.get_depth()

What can we say about d1, d2, d3 and d4?

  1. A

    d1 < d2 < d3 < d4

  2. B

    d1 ≤ d2 ≤ d3 ≤ d4

  3. C

    d1 > d2 > d3 > d4

  4. D

    d1 ≥ d2 ≥ d3 ≥ d4

Show answer

Correct answer

  • D

    d1 ≥ d2 ≥ d3 ≥ d4

Question 25

+4 marksOne correct option

Suppose that we have 10000 samples in a dataset. Suppose further we use the K − means algorithm to find clusters in the dataset. Then, the statement that K-Means algorithm always converges with zero inertia (or zero Sums Square Error) for some value of K is

  1. A

    Always True

  2. B

    Always False

  3. C

    True, sometimes

Show answer

Correct answer

  • A

    Always True

Question 26

+4 marksOne correct option

Suppose that we use k-means clustering for a dataset having 100 samples. The initial centroids for k clusters can be initialized in multiple ways. One such as way is shown below

  1. A

    20 centroids are randomly initialized 10 times

  2. B

    10 centroids are randomly initialized 20 times

  3. C

    20 samples in the dataset are selected as initialization point such that they are at least 10 units away from each other

  4. D

    10 samples in the dataset are selected as initialization point such that they are at least 20 units away from each other

Show answer

Correct answer

  • A

    20 centroids are randomly initialized 10 times

Question 27

+2 marksOne or more correct options

We wish to load the wine dataset from sklearn. Which of the following will throw an error?

Select all that apply.

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

Correct answers

  • A
  • B

Question 28

+2 marksOne or more correct options

Which of the following is correct?

Select all that apply.

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

Correct answers

  • B
  • D

Question 29

+2 marksOne or more correct options

Which of the following algorithms may get impacted by feature scaling?

Select all that apply.

  1. A

    LinearRegression

  2. B

    DecisionTree

  3. C

    SVM

  4. D

    BinomialNaiveBayes

Show answer

Correct answers

  • A

    LinearRegression

  • C

    SVM

Question 30

+2 marksOne or more correct options

Which of the following class(es) is (are) used to instantiate a neural network in Sklearn.

Select all that apply.

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

Correct answers

  • B
  • D

Question 31

+3 marksOne or more correct options

Following information about X_train is given:

  • Shape of X_train is (100,6)
  • 4 continuous features, 2 categorical features
  • One categorical feature contains 3 categories/unique values
  • Second categorical feature contains 4 categories/unique values
python
from sklearn.preprocessing import OneHotEncoder
Ohe = OneHotEncoder()
Encoded_X_train = ohe.fit_transform(X_train)
Encoded_X_train.shape

Which of the following is(are) correct option(s) for above information ?

Select all that apply.

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

Correct answers

  • A
  • C

Question 32

+3 marksOne or more correct options

Which of the following ways can help in feature selection?

Select all that apply.

  1. A

    Drop a Feature with many missing values

  2. B

    Drop a feature containing data with high standard deviation

  3. C

    Use SelectKBest or SelectKPercentile methods

  4. D

    Drop a feature which has high correlation with target variable

Show answer

Correct answers

  • A

    Drop a Feature with many missing values

  • C

    Use SelectKBest or SelectKPercentile methods

Question 33

+4 marksOne or more correct options

Consider the following block of code:

python
from sklearn.datasets import load_breast_cancer
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
X,y = load_breast_cancer(as_frame = True,
return_X_y = True)
X_train,X_test,y_train,y_test = train_test_split(X,
y,
test_size = 0.2,
random_state = 1)
clf = DecisionTreeClassifier(min_samples_split = 6, min_samples_leaf = 4,
random_state = 5)
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))

In which of the following scenarios, the split will NOT be done at node N?

Select all that apply.

  1. A

    Number of samples at node N = 15. If it is split, it will result in 9 nodes in the left child and 6 nodes in the right child.

  2. B

    Number of samples at node N = 5. If it is split, it will result in 4 nodes in the left child and 2 nodes in the right child.

  3. C

    Number of samples at node N = 7. If it is split, it will result in 4 nodes in the left child and 3 nodes in the right child.

  4. D

    Number of samples at node N = 12. If it is split, it will result in 3 nodes in the left child and 9 nodes in the right child.

Show answer

Correct answers

  • B

    Number of samples at node N = 5. If it is split, it will result in 4 nodes in the left child and 2 nodes in the right child.

  • C

    Number of samples at node N = 7. If it is split, it will result in 4 nodes in the left child and 3 nodes in the right child.

  • D

    Number of samples at node N = 12. If it is split, it will result in 3 nodes in the left child and 9 nodes in the right child.

Question 34

+4 marksOne or more correct options

The code given below attempts to find the clusters in the dataset, X using the K-means algorithm.

Select all that apply.

  1. A

    The code attempts to find 2 clusters in the given dataset

  2. B

    The dataset X can be visualized in the Euclidean space

  3. C

    The code raises an error upon execution

  4. D

    The code gets executed without an error upon execution

Show answer

Correct answers

  • B

    The dataset X can be visualized in the Euclidean space

  • C

    The code raises an error upon execution

Question 35

+4 marksOne or more correct options

The following line of code creates a neural network (assume necessary imports)

Select the correct statements from the following list of statements

Select all that apply.

  1. A

    The neural network contains 3 hidden layers with 5 neurons in each hidden layer

  2. B

    The neural network contains 5 hidden layers with 3 neurons in each hidden layer

  3. C

    The neural network contains 2 hidden layers with 5 neurons in the second hidden layer

  4. D

    The neural network contains 2 hidden layers with 3 neurons in the first hidden layer

  5. E

    None of the given options are correct

Show answer

Correct answers

  • C

    The neural network contains 2 hidden layers with 5 neurons in the second hidden layer

  • D

    The neural network contains 2 hidden layers with 3 neurons in the first hidden layer

Question 36

+3 marksNumerical answer

Consider the following code block:

python
from sklearn.model_selection import GridSearchCV
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import make_classification
X, y = make_classification(n_samples = 100, n_features = 3,
n_informative = 2, n_redundant = 1)
param_grid = [{'max_depth': [2, 3, 4, 5, 6], 'min_samples_split': [2, 3, 4, 5, 6]},
{'min_samples_leaf': [2, 3, 4, 5, 6]},
{'min_impurity_decrease': [0.2, 0.3, 0.4, 0.5, 0.6],
'ccp_alpha': [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]}]
gscv = GridSearchCV(DecisionTreeClassifier(), param_grid, cv = 3)
gscv.fit(X, y)
print(gscv.best_params_)

How many parameter combinations will be tried by GridSearchCV?

Show answer

Correct answer: 60