Quiz Space

September 2022 term · Machine Learning Practice · BSCS2008

MLP End Term: 11 December 2022, Set ETD1 (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: 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
29
MSQ
5
Numerical
4

Updated

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

Question 1

+2 marksOne correct option

What will be the shape of X and y?

  1. A

    (120,90) and (120,)

  2. B

    (120,10) and (120,)

  3. C

    (90,120) and (90,)

  4. D

    (90,10) and (90,)

Show answer

Correct answer

  • A

    (120,90) and (120,)

Question 2

+2 marksOne correct option

What will be the shape of the feature matrix (X.shape) and the label vector (y.shape) for the following block of code?

  1. A

    (699, 1) and (599, 1)

  2. B

    (500, 1) and (500, 1)

  3. C

    (1, 500) and (1,500)

  4. D

    (599, 1) and (699, 1)

Show answer

Correct answer

  • B

    (500, 1) and (500, 1)

Question 3

+2 marksOne correct option

What will be the output of the following code?

python
from sklearn.datasets import load_wine
one = load_wine()
two = load_wine(return_X_y = False)
three = load_wine(as_frame = False)
four = load_wine(as_frame = False, return_X_y = False)
print(type(one))
print(type(two))
print(type(three))
print(type(four))
  1. A

    Bunch, Tuple, DataFrame, DataFrame

  2. B

    Bunch, Tuple, DataFrame, Tuple

  3. C

    Bunch, Bunch, Bunch, Bunch

  4. D

    DataFrame, DataFrame, DataFrame, DataFrame

  5. E

    Bunch, Ndarray, Bunch, Ndarray

  6. F

    It will result into an error.

Show answer

Correct answer

  • C

    Bunch, Bunch, Bunch, Bunch

Question 4

+2 marksOne correct option

Consider following code snippet:

Above classifier uses:

  1. A

    hinge but quadratically penalized.

  2. B

    logistic regression.

  3. C

    linear SVM.

  4. D

    None of these.

  5. E

    perceptron.

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 has discrete features that are categorically distributed?

  1. A

    GaussianNB

  2. B

    CategoricalNB

  3. C

    ComplementNB

  4. D

    None of these

Show answer

Correct answer

  • B

    CategoricalNB

Question 6

+2 marksOne correct option

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

  1. A

    [0]

  2. B

    [2]

  3. C

    [1.5]

  4. D

    [1]

Show answer

Correct answer

  • B

    [2]

Question 7

+2 marksOne correct option

Which of the following estimators implement partial_fit method in Regression?

  1. A

    Ridge Regression

  2. B

    SGDRegressor

  3. C

    Linear Regression

  4. D

    Polynomial Regression

Show answer

Correct answer

  • B

    SGDRegressor

Question 8

+2 marksOne correct option

Mention which of the following statement(s) is / are correct?
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.
Statement 2: Sklearn can not process large data in batches.

  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

  • A

    Statement 1 is correct but statement 2 is incorrect.

Question 9

+2 marksOne correct option

Which of the following options represents the correct value of gamma for SVC_classifier = SVC(gamma = ’auto’)?

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

Correct answer

  • C

Question 10

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

  2. B

    Data 3

  3. C

    Data 4

  4. D

    Data 2

Show answer

Correct answer

  • A

    Data 1

Question 11

+2 marksOne correct option

When a node is split further in a decision tree:

  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

Which of the following is/are Correct for K-means algorithm.

  1. A

    The algorithm is sensitive to outliers.

  2. B

    It terminates at a local optimum if SSE is used.

  3. C

    k-means is considered to be a linear algorithm.

  4. D

    All of these

Show answer

Correct answer

  • D

    All of these

Question 13

+2 marksOne correct option

Hierarchical Clustering can also be called:

  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

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answers

  • C

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

  • D

    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

Which of the following statements correctly set L1 penalty to 0.2 and L2 Penalty to 0.8 in LogisticRegression?

Select all that apply.

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

Correct answer

  • A

Question 16

+2 marksOne or more correct options

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

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 17

+3 marksOne or more correct options

Which of the following statements are incorrect about the AUC?

Select all that apply.

  1. A

    The ROC curve plots sensitivity (recall) on the x-axis against specificity on the y- axis

  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 less 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 answers

  • A

    The ROC curve plots sensitivity (recall) on the x-axis against specificity on the y- axis

  • C

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

Question 18

+3 marksNumerical answer

The output of the following block of code will be:

Show answer

Correct answer: 4

Question 19

+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
0juli228478
1nick517661
2tom417681
3Abhi566782
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: 23 (accepted within ±0.05)

Question 20

+3 marksNumerical answer

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

Show answer

Correct answer: 0.75

Question 21

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

Question 22

+3 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.833 , Recall: 0.875, Accuracy: 0.833

  2. B

    Precision: 0.875, Recall: 0.833, Accuracy: 0.833

  3. C

    Precision: 0.9783, Recall: 0.9281, Accuracy: 0.909

  4. D

    None of these

Show answer

Correct answer

  • A

    Precision: 0.833 , Recall: 0.875, Accuracy: 0.833

Question 23

+3 marksOne correct option

Consider the following code snippet:

which of the following could be the correct output?

  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

  • A

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

Question 24

+3 marksOne correct option

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

  1. A

    [0.95238095, 0. ]

  2. B

    [0.85,0.1,0.05]

  3. C

    [2,3,1]

  4. D

    [0.85,0]

  5. E

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

Show answer

Correct answer

  • A

    [0.95238095, 0. ]

Question 25

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

Show answer

Correct answer

  • D

    0.82

Question 26

+3 marksOne correct option

Mention whether the following statements are TRUE or FALSE .
Statement 1 : ‘In order to extend ROC curve and ROC area to multi-label classification, it is necessary to binarize the output.‘
Statement 2: In SGDClassifier, setting warm_start=True does not retain the weight values of the model after max_iter and hence does not produce different results for each execution.‘

  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

  • A

    Statement 1 is correct but statement 2 is incorrect.

Question 27

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

  • D

Question 28

+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, 10)

  3. C

    (1, 11)

  4. D

    (10, 1)

Show answer

Correct answer

  • B

    (1, 10)

Question 29

+3 marksOne correct option

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

  1. A

    array([, ’is’, ’name’, ’the’], dtype=object)

  2. B

    array([’bond’, ’is’, ’james’, ’name’, ’the’,’ !’], dtype=object)

  3. C

    array([’bond’, ’bond’, ’is’, ’james’, ’name’, ’the’], dtype=object)

  4. D

    array([’bond’, ’is’, ’james’, ’name’, ’the’], dtype=object)

Show answer

Correct answer

  • D

    array([’bond’, ’is’, ’james’, ’name’, ’the’], dtype=object)

Question 30

+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

  • A

    array([2])

Question 31

+3 marksOne correct option

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

  1. A

    2, 3

  2. B

    1, 3, 5

  3. C

    3, 5

  4. D

    2, 4

  5. E

    1, 3, 4

  6. F

    1, 2, 4

Show answer

Correct answer

  • A

    2, 3

Question 32

+3 marksOne correct option

Lata wants to train a bagging regressor with following specifications:
1. Base estimator as linear regressor with default parameter values.
2. 80% of the data is used to create a bag of samples.
3. Create subsets of training set without replacement.
4. Take half the features when creating subsets of data.
5. Train the model on training set.
6. Print score on test set.
Which of the following code blocks will correctly execute Lata’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 33

+3 marksOne correct option

You have a binary classification problem to solve with following information:
1. All features are numircal.
2. The dataset has size of 80 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 LogisticRegression model (sklearn.linear_model).

  2. B

    Perform standard scaling followed by a
    sklearn.neighbors.KNeighborsClassifier model.

  3. C

    Perform min-max scaling followed by a sklearn.tree.DecisionTreeClassifier model.

  4. D

    Perform max-absolute scaling followed by a
    sklearn.linear_model.SGDClassifier model.

Show answer

Correct answer

  • D

    Perform max-absolute scaling followed by a
    sklearn.linear_model.SGDClassifier model.

Question 34

+3 marksOne correct option

Let data-set XX has 784 features and the trained using the following code:

python
mlp_clf = MLPClassifier(hidden_layer_sizes=(100,),
alpha=1e-4,
solver="sgd",
learning_rate_init=0.2,
max_iter=50,
random_state=1)
mlp_clf.fit(X, y)

What will be the output of following code:

python
w = mlp_clf.coefs_
w = np.array(w[0])
w.shape
  1. A

    (784, 100)

  2. B

    (784, 1)

  3. C

    (1, 784)

  4. D

    (100, 784)

Show answer

Correct answer

  • A

    (784, 100)

Question 35

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

  4. D

    0.223

  5. E

    0.533

Show answer

Correct answer

  • D

    0.223

Question 36

+4 marksOne correct option

Brajesh 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 30 to 40 (both inclusive) at the interval of 1.
3. Cross validation = 5.
4. Learning rate must vary between 0.2 to 2.0 (both inclusive) at the intervals of 0.2.
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 Brajesh’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 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.005, 1, 0.05)
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.055

  2. B

    0.05

  3. C

    0.905

  4. D

    0.1

  5. E

    1

Show answer

Correct answers

  • A

    0.055

  • C

    0.905

Question 38

+3 marksOne correct option

Go through the code snippet given below and answer the 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.005, 1, 0.05)
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

    -2999.79

  3. C

    0.528

  4. D

    0.681

Show answer

Correct answer

  • B

    -2999.79