Quiz Space

January 2023 term · Machine Learning Practice · BSCS2008

MLP End Term: 30 April 2023, Set QPD2-S1 (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 QPD2-S1: 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
19
MSQ
15
Numerical
2

Updated

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

Question 1

+2 marksOne correct option

To load datasets from openml.org, which method will be appropriate?

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

Correct answer

  • D

Question 2

+2 marksOne correct option

Why is data preprocessing necessary?

  1. A

    Some columns have values only between 0 and 1.

  2. B

    A column has same entities with different names, e.g. ”India”, ”In”, ”IN”.

  3. C

    The data has only numbers in all the columns.

Show answer

Correct answer

  • B

    A column has same entities with different names, e.g. ”India”, ”In”, ”IN”.

Question 3

+2 marksOne correct option

Consider the following code block:

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

Correct answer

  • D

Question 4

+2 marksOne correct option

Which of the following sklearn classes will be the most suitable for examining the effect of the number of samples on the training and testing errors?

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

Correct answer

  • D

Question 5

+2 marksOne correct option

Which of the following is not a hyper parameter?

  1. A

    degree in Polynomial Regression

  2. B

    k in KNN

  3. C

    intercept value in linear regression

  4. D

    depth of tree in a decision tree

Show answer

Correct answer

  • C

    intercept value in linear regression

Question 6

+2 marksOne correct option

Consider following two statements:
Statement 1: The multinomial Naive Bayes classifier is suitable for classification with discrete features
Statement 2: Two dependent features impact GaussianNB performance because internally it calculates the conditional probability.

  1. A

    Both statements are True

  2. B

    Only statement 1 is True

  3. C

    Only statement 2 is True

  4. D

    Both statements are False

Show answer

Correct answer

  • A

    Both statements are True

Question 7

+2 marksOne correct option

Given below code to load a huge file name as filename.csv and this file is not loading at once in the system which parameter should be added to pd.read_csv to load this file ?

python
import pandas as pd
from sklearn.linear_model import SGDRegressor
for train_df in pd.read_csv("filename.csv", __________=1024):
X = train_df.iloc[:, :-1]
y = train_df.iloc[:, -1]
model = SGDRegressor()
model.partial_fit( X,y)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 8

+2 marksOne correct option

Which of the following is true for a hard margin SVM algorithm ?

  1. A

    It does not create hyperplanes as decision boundary

  2. B

    It can only work for linearly separable data

  3. C

    It is robust to outliers

  4. D

    It is mostly used for clustering the data

Show answer

Correct answer

  • B

    It can only work for linearly separable data

Question 9

+2 marksOne correct option

What will the output for below code

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

Correct answer

  • A

Question 10

+3 marksOne correct option

Which of the following APIs can be used to construct an ML pipeline that has numerical and categorical features both? Choose the most suitable answer.

  1. A

    Pipeline alone

  2. B

    ColumnTransformer with pipeline

  3. C

    FeatureUnion with ColumnTransformer and/or pipeline

  4. D

    All of these

Show answer

Correct answer

  • C

    FeatureUnion with ColumnTransformer and/or pipeline

Question 11

+3 marksOne correct option

Consider the following preprocessing steps:
1. Read the data from a file (named ‘dataset.csv’). It has 4 columns, with following column names ‘city’, ‘title’, ‘expert_rating’ and ‘user_rating’ in this order.
2. Drop rows with missing values.
3. Apply ‘CountVectorizer’ on ‘title’.
4. Apply one hot encoding to ‘city’.
5. Drop the remaining columns.
6. Fit and transform the data and print it.
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 12

+3 marksOne correct option

Consider the following code block:

python
from sklearn.datasets import make_regression
X, y = make_regression(n_samples = 1000,
n_features = 5,
n_informative = 2,
random_state=42)
from sklearn.linear_model import SGDRegressor
sgd1 = SGDRegressor(alpha=1e-3,
random_state=42,
penalty='_________________', )
sgd1.fit(X, y)
print(sgd1.coef_)
sgd2 = SGDRegressor(alpha=1e-3,
random_state=42,
penalty='__________________')
sgd2.fit(X, y)
print(sgd2.coef_)

What are the most suitable values to be filled in the two blank spaces (in that order) in the code to expect the following output?:

[ 1.68059576e+01, 1.89752021e+01, 7.49212536e-04, -6.53455275e-04, 3.01471918e-04]

[16.82258106, 18.99248887, 0., 0., 0.]

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

Correct answer

  • C

Question 13

+3 marksOne correct option

What will be the output of the following code?:

  1. A

    (10, 2)

  2. B

    (10, 4)

  3. C

    (10, 5)

  4. D

    (10, 6)

Show answer

Correct answer

  • B

    (10, 4)

Question 14

+3 marksOne correct option

Consider following model:

python
estimator = SGDClassifier(loss='log',
penalty='l2',
max_iter=1,
warm_start=True,
eta0=0.01,
alpha=0,
learning_rate='constant',
random_state=1729)
pipe_sgd= make_pipeline(MinMaxScaler(), estimator)

Which of the following code snippets will plot the learning curve for training for 100 epochs? Assume necessary imports and the variable names suggest the data they hold/point to.

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

    None of these

Show answer

Correct answer

  • A

Question 15

+3 marksOne correct option

If we need quick results during the testing phase, then which classification techniques may not be appropriate?

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

Correct answer

  • B

Question 16

+3 marksOne correct option

Following is the code to tune the degree parameter of a polynomial regression model.

python
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import SGDRegressor
param_grid = [{_________: [2, 3, 4, 5, 6, 7, 8, 9]}]
pipeline = Pipeline(steps=[('poly', PolynomialFeatures()),
('sgd', SGDRegressor())])
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

  • E

Question 17

+4 marksOne correct option

The following code produces an output of 0.9125. How is the output expected to change if we increase the max_depth value?:

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.10,
random_state = 12)
clf = DecisionTreeClassifier(max_depth = 2,
min_samples_split = 2,
min_samples_leaf=3,
random_state = 81)
clf.fit(X_train, y_train)
print(clf.score(X_train, y_train))
  1. A

    Output score is likely to increase.

  2. B

    Output score is likely to decrease.

  3. C

    Output score may increase or decrease.

  4. D

    Output score will remain the same.

Show answer

Correct answer

  • A

    Output score is likely to increase.

Question 18

+4 marksOne correct option

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

  1. A

    20

  2. B

    75

  3. C

    8

  4. D

    15

  5. E

    40

Show answer

Correct answer

  • B

    75

Question 19

+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 = 7,
min_samples_leaf = 4,
random_state = 5)
clf1.fit(X_train, y_train)
clf2 = DecisionTreeClassifier(min_samples_split = 4,
min_samples_leaf = 2,
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

  • B

    depth(clf1) ≤ depth(clf2)

Question 20

+2 marksOne or more correct options

Consider the following code:

Select all that apply.

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

Correct answers

  • A
  • B
  • C
  • D

Question 21

+2 marksOne or more correct options

Consider the following code block with respect to some dataset contained in X and y.

python
from sklearn.linear_model import linear_regression
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import ShuffleSplit
lin_reg = linear_regression()
shuffle_split = ShuffleSplit(n_splits=5, test_size=0.2, random_state=42)
score = cross_val_score(lin_reg, X, y, cv=shuffle_split,
scoring='-----------------------')

Which of the following may be appropriate to be filled in the blank space?

Select all that apply.

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

Correct answers

  • A
  • D

Question 22

+2 marksOne or more correct options

Which of the following models are inherently multiclass models?

Select all that apply.

  1. A

    KNN

  2. B

    Decision trees

  3. C

    Perceptron

  4. D

    Logistic regression

Show answer

Correct answers

  • A

    KNN

  • B

    Decision trees

Question 23

+2 marksOne or more correct options

Which of the following is/are correct regarding Radius Neighbors Classifier

Select all that apply.

  1. A

    Only 5 neighbours in the range of some radius are used to compute the label of a sample.

  2. B

    All the neighbours in the range of some radius are used to compute the label of a sample.

  3. C

    It is sensitive to outliers.

  4. D

    It is not sensitive to outliers.

Show answer

Correct answers

  • B

    All the neighbours in the range of some radius are used to compute the label of a sample.

  • D

    It is not sensitive to outliers.

Question 24

+2 marksOne or more correct options

Which options are correct for large datasets that don’t fit into the system’s main memory?

Select all that apply.

  1. A

    No data preprocessing can be performed.

  2. B

    One hot encoding can not be applied directly or by iteratively learning one hot encoder’s parameters and then applying one hot encoding in batches.

  3. C

    Standard scaling parameters can be learnt iteratively then standard scaling can be applied in batches.

  4. D

    One hot encoding and standard scaling can be applied directly or iteratively.

Show answer

Correct answers

  • B

    One hot encoding can not be applied directly or by iteratively learning one hot encoder’s parameters and then applying one hot encoding in batches.

  • C

    Standard scaling parameters can be learnt iteratively then standard scaling can be applied in batches.

Question 25

+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

    SGDClassifier()

  2. B

    MLPClassifier()

  3. C

    NNClassifier()

  4. D

    MLPRegressor()

Show answer

Correct answers

  • B

    MLPClassifier()

  • D

    MLPRegressor()

Question 26

+3 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

  • A
  • C
  • D

Question 27

+3 marksOne or more correct options

Which of the following processes should be done if we get an imbalanced dataset? Data is imbalanced when the target class has an uneven distribution of label values.

Select all that apply.

  1. A

    Remove all the minority classes

  2. B

    Remove all the majority classes

  3. C

    Up-sample the minority classes

  4. D

    down-sample the majority classes

Show answer

Correct answers

  • C

    Up-sample the minority classes

  • D

    down-sample the majority classes

Question 28

+3 marksOne or more correct options

Which of the following is true about Naive Bayes algorithm ?

Select all that apply.

  1. A

    It is primarily used for regression problems

  2. B

    It is primarily used for classification problems

  3. C

    Hyperparameter tuning is required

  4. D

    Hyperparameter tuning is not required

Show answer

Correct answers

  • B

    It is primarily used for classification problems

  • D

    Hyperparameter tuning is not required

Question 29

+3 marksOne or more correct options

Select all that apply.

  1. A

    Data is continuously being generated

  2. B

    Data is generated every month

  3. C

    Whole data is generated and its in a huge file size

  4. D

    For very small dataset

Show answer

Correct answers

  • A

    Data is continuously being generated

  • B

    Data is generated every month

  • C

    Whole data is generated and its in a huge file size

Question 30

+3 marksOne or more correct options

Which options are correct for Support Vectors in SVM ?

Select all that apply.

  1. A

    Support vectors are the data points nearest to the hyperplane

  2. B

    Using these support vectors, we maximize the margin of the classifier.

  3. C

    Using these support vectors, we minimize the margin of the classifier.

  4. D

    None of these

Show answer

Correct answers

  • A

    Support vectors are the data points nearest to the hyperplane

  • B

    Using these support vectors, we maximize the margin of the classifier.

Question 31

+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 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

  • 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.

  • 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.

Question 32

+4 marksOne or more correct options

Suppose we want to choose the best value of k in k−means clustering algorithm using Silhouette Coefficient values. Which of the following are required to compute the coefficient value? Note: Labels (cluster number) of the samples are random. There is no functional relationship between a sample and its label

Select all that apply.

  1. A

    All the samples in the dataset

  2. B

    A few randomly selected samples in the dataset

  3. C

    The number of clusters k, such that k ≥ 2

  4. D

    The number of clusters k, such that k ≥ 1

Show answer

Correct answers

  • A

    All the samples in the dataset

  • C

    The number of clusters k, such that k ≥ 2

Question 33

+4 marksOne or more correct options

Which of the following approach(es) is(are) helpful to find a good value for k in k−means clustering algorithm?

Select all that apply.

  1. A

    Plotting an Elbow curve

  2. B

    Using GridSearchCV or RandomizedSearchCV for various values of k

  3. C

    Plotting Silhouette coefficient for various values of k

  4. D

    Using k-fold cross validation

Show answer

Correct answers

  • A

    Plotting an Elbow curve

  • C

    Plotting Silhouette coefficient for various values of k

Question 34

+4 marksOne or more correct options

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

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 3 neurons in the second hidden layer

  4. D

    The neural network contains 2 hidden layers with 5 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 3 neurons in the second hidden layer

  • D

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

Question 35

+2 marksNumerical answer

What will be the output of the following code?:

Show answer

Correct answer: 0.9 (accepted within ±0.05)

Question 36

+4 marksNumerical answer

The plot below shows a distribution of 200 samples with 2 features in Euclidean space. Suppose we use the K-means clustering algorithm to group these data points into individual clusters. Enter the value of K for which the inertia (Sum Square Error) will be zero. If you conclude, there is no such value for K, then enter -1.

Show answer

Correct answer: 200