Quiz Space

May 2024 term · Machine Learning Practice · BSCS2008

MLP End Term: 1 September 2024, Set QDF3 (May 2024 term)

The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 1 Sept 2024, in the May 2024 term, set QDF3: 37 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
37
Marks
100
Duration
180 min
MSQ
13
Numerical
5
MCQ
19

Updated

Official paper: IIT M FOUNDATION DIPLOMA AN EXAM QDF3 01 Sep 2024 · No negative marking.

Question 1

+2 marksOne or more correct options

Consider the following common data and answer the subquestion:

Consider the following code snippet:

Which of the following will be equivalent to the above code snippet?

Select all that apply.

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

Correct answers

  • A
  • C

Question 2

+2 marksNumerical answer

Consider the following common data and answer the subquestion:

What is the output of the following code snippet:

Enter -1, if you think the above statement will generate an error.

Show answer

Correct answer: 120

Question 3

+2 marksNumerical answer

Consider the following common data and answer the subquestion:

What is the output of the following code snippet:

Enter -1, if you think the above statement will generate an error.

Show answer

Correct answer: 3

Question 4

+2 marksNumerical answer

Consider the following common data and answer the subquestion:

What is the output of the following code snippet:

Enter -1, if you think the above statement will generate an error.

Show answer

Correct answer: -1

Question 5

+2 marksOne correct option

Consider the following common data and answer the subquestion:

What is the output of the following code snippet:

Choose correct options from following:

  1. A

    The number of rows will decrease in the dataset.

  2. B

    The number of columns will decrease in the dataset.

  3. C

    The number of columns and number of rows, both, will decrease in the dataset.

  4. D

    There will be no change.

  5. E

    Insufficient information.

Show answer

Correct answer

  • A

    The number of rows will decrease in the dataset.

Question 6

+2 marksOne correct option

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

  1. A

    load_openml()

  2. B

    read_openl()

  3. C

    read_data()

  4. D

    fetch_openml()

  5. E

    load_data()

  6. F

    load_csv()

  7. G

    fetch_csv()

Show answer

Correct answer

  • D

    fetch_openml()

Question 7

+2 marksOne correct option

In which of the option given below data preprocessing is required?

  1. A

    In some columns which has values between 0 and 1.

  2. B

    A column contains entity names such as ‘Chennai’, ‘CHENNAI’ and ‘MADRAS’.

  3. C

    The data has only numbers in all the columns.

Show answer

Correct answer

  • B

    A column contains entity names such as ‘Chennai’, ‘CHENNAI’ and ‘MADRAS’.

Question 8

+2 marksOne correct option

Consider the following code block:

python
X = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
from sklearn.model_selection import KFold
kf = KFold(n_splits = 3)
for train, test in kf.split(X):
print(train, test)

Which of the following may be the correct output of the above code?

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

Correct answer

  • B

Question 9

+2 marksOne correct option

Which of the following scikit-learn classes is best suited for examining how the number of samples impacts training and testing errors?

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

Correct answer

  • D

Question 10

+2 marksOne correct option

Consider following two statements:
Statement 1: The GaussianNB classifier can incrementally learn using partial_fit.
Statement 2: GaussianNB performance suffers when features are dependent, as it assumes independence in calculating conditional probabilities.

  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 11

+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(prep_X,y)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 12

+2 marksOne correct option

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

  1. A

    It does not create hyperplanes as a decision boundary

  2. B

    It will correctly classify all the data point if the data is linearly separable

  3. C

    It is robust to outliers

  4. D

    It is mostly used for clustering the data

Show answer

Correct answer

  • B

    It will correctly classify all the data point if the data is linearly separable

Question 13

+2 marksOne correct option

What could be the output for below code

python
from sklearn.feature_extraction.text import CountVectorizer
corpus = [ 'This is the first document.',
'This document is the second document.']
vectorizer = CountVectorizer()
vectorizer.fit_transform(corpus)
print(vectorizer.vocabulary_)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 14

+2 marksOne correct option

Decision Trees are prone to:

  1. A

    Low bias, low variance

  2. B

    High bias, low variance

  3. C

    Low bias, high variance

  4. D

    High bias, high variance

Show answer

Correct answer

  • C

    Low bias, high variance

Question 15

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

+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 = 4,
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?:

python
[48.50064306, 0 , 0 , 8.53931469]
[4.84494867e+01, -7.58443057e-04, -2.09844306e-03, 8.53220113e+00]
  1. A

    ‘l1’, ‘l2’

  2. B

    ‘l1’, None

  3. C

    ‘l2’, ‘l1’

  4. D

    ‘l2’, None

Show answer

Correct answer

  • A

    ‘l1’, ‘l2’

Question 17

+3 marksOne correct option

Consider following code:

python
estimator = SGDClassifier(loss='log_loss',
penalty='l2',
max_iter=1,
warm_start="_____",
eta0=0.01,
alpha=0,
learning_rate='constant',
)
pipe_sgd= make_pipeline(MinMaxScaler(), estimator)

Which of the following is a suitable choice for warm_start if you wanted to plot learning curve with decreasing loss when trained for 100 epochs? Make necessary assumptions.

  1. A

    True

  2. B

    False

  3. C

    Yes

  4. D

    No

  5. E

    None of these

Show answer

Correct answer

  • A

    True

Question 18

+3 marksOne correct option
  1. A

    It controls the number of weak learners.

  2. B

    It shrinks the contribution of each classifier.

  3. C

    It sets the weight of each weak learner.

  4. D

    It adjusts the speed at which the model learns.

Show answer

Correct answer

  • B

    It shrinks the contribution of each classifier.

Question 19

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

+4 marksOne correct option

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

python
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import GridSearchCV
param_grid = [{'max_depth':range(1, 10, 2),
'min_samples_split': range(1, 10, 3)}]
gs = GridSearchCV(DecisionTreeClassifier(), param_grid, cv = 5)
gs.fit(X,y)
  1. A

    20

  2. B

    75

  3. C

    8

  4. D

    15

  5. E

    40

Show answer

Correct answer

  • D

    15

Question 21

+4 marksOne correct option

Consider the following code for a VotingClassifier. What is the effect of setting voting='soft'?

python
from sklearn.ensemble import VotingClassifier
clf1 = LogisticRegression()
clf2 = RandomForestClassifier()
clf3 = SVC(probability=True)
eclf = VotingClassifier(estimators=[('lr', clf1),
('rf', clf2),
('svc', clf3)],
voting='soft')
eclf.fit(X_train, y_train)
  1. A

    The final predictions are based on the majority vote.

  2. B

    The final predictions are based on the average of probabilities predicted by each classifier.

  3. C

    The final predictions are based on the weighted sum of the predictions.

  4. D

    The final predictions are based on the classifier with the highest accuracy.

Show answer

Correct answer

  • B

    The final predictions are based on the average of probabilities predicted by each classifier.

Question 22

+4 marksOne correct option
  1. A

    The mean accuracy across all cross-validation folds.

  2. B

    The mean precision across all cross-validation folds.

  3. C

    The mean recall across all cross-validation folds.

  4. D

    The mean F1 score across all cross-validation folds.

Show answer

Correct answer

  • A

    The mean accuracy across all cross-validation folds.

Question 23

+4 marksOne correct option
  1. A

    Plotting the sum of the squared distances of samples to their closest cluster center

  2. B

    by Changing the distance metric for KMeans

  3. C

    By initialising clustering centroids very far from each other

  4. D

    All of these

Show answer

Correct answer

  • A

    Plotting the sum of the squared distances of samples to their closest cluster center

Question 24

+2 marksOne or more correct options

Consider the following code:

python
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
X, y = load_iris(return_X_y = True)

The sizes of X and y are (150, 4) and (150,) respectively. Which of the following would be the correct code snippet to split X and y into training and test data such that test data has exactly 30 samples?

Select all that apply.

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

Correct answers

  • A
  • D

Question 25

+2 marksOne or more correct options

Consider the following code block:

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 26

+2 marksOne or more correct options

Which of the following is a hyper parameter?

Select all that apply.

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

Correct answers

  • B
  • C
  • D

Question 27

+2 marksOne or more correct options

Which of the following models are inherently multiclass models?

Select all that apply.

  1. A

    Perceptron

  2. B

    DecisionTreeClassifier

  3. C

    KNeighborClassifier

  4. D

    LogisticRegression

Show answer

Correct answers

  • B

    DecisionTreeClassifier

  • C

    KNeighborClassifier

Question 28

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

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

Question 30

+3 marksOne or more correct options

Which of the following processes can be done if we have a dataset with imbalanced target class distribution?

Select all that apply.

  1. A

    Remove all the minority classes

  2. B

    Up-sample the minority classes

  3. C

    Remove all the majority classes

  4. D

    Down-sample the majority classes

  5. E

    create synthetic samples to balance the classes

Show answer

Correct answers

  • B

    Up-sample the minority classes

  • D

    Down-sample the majority classes

  • E

    create synthetic samples to balance the classes

Question 31

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

+3 marksOne or more correct options

Which of the following is/are correct regarding RadiusNeighborsClassifier

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 33

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

+4 marksOne or more correct options

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

    All 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

+5 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=42)
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 can happen 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 samples in the left child node and 6 sample in the right child node.

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answers

  • A

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

  • D

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

Question 36

+2 marksNumerical answer
Show answer

Correct answer: 0.3235 (accepted within ±0.0045)

Question 37

+4 marksNumerical answer
Show answer

Correct answer: 180