uiz Space

September 2022 term · Machine Learning Practice · BSCS2008

Machine Learning Practice Quiz 1: 16 October 2022 (September 2022 term)

The IIT Madras BS Machine Learning Practice (MLP) Quiz 1 paper sat on 16 Oct 2022, in the September 2022 term: 20 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
20
Marks
50
Duration
120 min
MCQ
16
MSQ
3
Numerical
1

Updated

Official paper: IIT M QUIZ 1 FOUNDATION DAD DIPLOMA QPD2 16 Oct 2022 · No negative marking.

Question 1

+1 markOne correct option

The violin plot shown in Figure 2 demonstrates the age of passengers on the Titanic ship. Mark the approximate age range of most of the passengers.

  1. A

    20 - 40

  2. B

    80 above

  3. C

    Less than 20

  4. D

    40-60

Show answer

Correct answer

  • A

    20 - 40

Question 2

+2 marksOne correct option

Which of the following Sklearn objects can help you to reduce, expand or generate feature representations?

  1. A

    Estimator

  2. B

    Predictor

  3. C

    Transformer

  4. D

    None of these

Show answer

Correct answer

  • C

    Transformer

Question 3

+2 marksOne correct option

What will be the output of the following code?

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

Correct answer

  • A

Question 4

+2 marksOne correct option

Go through the code snippet given below:

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

  1. A

    (2000, 12) and (1000, 6)

  2. B

    (1, 1000) and (1,1000)

  3. C

    (599, 1) and (699, 1)

  4. D

    (1000, 6) and (1000,)

Show answer

Correct answer

  • D

    (1000, 6) and (1000,)

Question 5

+2 marksOne correct option

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

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

Correct answer

  • A

Question 6

+2 marksOne correct option

In the figure 1, what are the names of classes arranged in the increasing order of the median values?

  1. A

    First < Second < Third

  2. B

    Third < Second < First

  3. C

    Second < Third < First

  4. D

    Third < First < Second

Show answer

Correct answer

  • B

    Third < Second < First

Question 7

+2 marksOne correct option

Go through the code snippet given below and mark the correct output.

  1. A

    1

  2. B

    3

  3. C

    9

  4. D

    25

  5. E

    4

  6. F

    5

Show answer

Correct answer

  • F

    5

Question 8

+2 marksOne correct option

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

  1. A

    12

  2. B

    29

  3. C

    No evaluation metrics are mentioned, hence it will produce an error

  4. D

    0.96

Show answer

Correct answer

  • D

    0.96

Question 9

+3 marksOne correct option

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

python
from math import nan
import numpy as np
from sklearn.impute import SimpleImputer
data=[(2,3),(4,5),(3,1),(1,2),(5, nan)]
imputer = SimpleImputer(missing_values = np.nan, strategy ='mean',
add_indicator=True)
imputer = imputer.fit(data)
data_imputed_with_indicator = imputer.transform(data)
print (data_imputed_with_indicator)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 10

+3 marksOne correct option

Consider the following code snippet:

Which of the following could be the correct output?

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

Correct answer

  • A

Question 11

+3 marksOne correct option

Which of the following options will be the correct output of print(clf.coef_)?

  1. A

    [ 0.35 -0. -0. ]

  2. B

    [-0.85,0]

  3. C

    [3,2,1,2]

  4. D

    Given code block will return an error.

Show answer

Correct answer

  • A

    [ 0.35 -0. -0. ]

Question 12

+3 marksOne correct option

Go through the code snippet given below and mark the correct output.

  1. A

    0.61

  2. B

    0.83

  3. C

    0.95

  4. D

    1

  5. E

    -0.6

  6. F

    5

Show answer

Correct answer

  • C

    0.95

Question 13

+3 marksOne correct option

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

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

Correct answer

  • D

Question 14

+3 marksOne correct option

Which of the following code blocks will correctly take the learning rate as‘optimal’ ?

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

Correct answer

  • A

Question 15

+2 marksOne or more correct options

Which of the following code blocks will correctly return an array of feature variables?

Select all that apply.

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

Correct answers

  • B
  • D

Question 16

+3 marksOne or more correct options

Scikit-Learn’s API is remarkably well designed. The main design principles are:-

Select all that apply.

  1. A

    Nonproliferation of classes

  2. B

    Sensible defaults

  3. C

    Consistency

  4. D

    Proportion

Show answer

Correct answers

  • A

    Nonproliferation of classes

  • B

    Sensible defaults

  • C

    Consistency

Question 17

+3 marksOne or more correct options

Go through the code block given below:

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
diabetes = load_diabetes(as_frame=True)
train_X= diabetes.data
train_y= diabetes.target
lf= np.logspace(-5, 0, num=6)
reg= Pipeline([("poly", PolynomialFeatures(degree=2)),
("feature_scaling", StandardScaler())
])
ridge= RidgeCV(alphas=lf,scoring= None,fit_intercept = False)
results = ridge.fit(train_X, train_y)
print(results.intercept_)

Which of the following can’t be the correct output of the given code block?

Select all that apply.

  1. A

    0.0

  2. B

    0.01

  3. C

    0.1

  4. D

    1

Show answer

Correct answers

  • B

    0.01

  • C

    0.1

  • D

    1

Question 18

+3 marksNumerical answer

Enter the correct output of the following code block.

python
import numpy as np
from sklearn.model_selection import ShuffleSplit
X = np.array([[2, 2], [5, 4], [1, 6], [2, 8], [3, 4], [2, 6]])
y = np.array([3, 2, 1, 2, 3, 2])
rs = ShuffleSplit(n_splits=5, test_size=.25, random_state=0)
k=1
for i,j in rs.split(X):
k+=1
print(k)
Show answer

Correct answer: 6

Question 19

+3 marksOne correct option

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

python
import numpy as np
from sklearn.linear_model import SGDRegressor
from sklearn.pipeline import make_pipeline
n_samples, n_features = 18, 4
rng = np.random.RandomState(0)
y = rng.randn(n_samples)
X = rng.randn(n_samples, n_features)
reg = SGDRegressor(max_iter=1000,tol=1e-3,eta0= 0.04, power_t=5,
n_iter_no_change=3, validation_fraction=0.3 ,random_state=42)
reg.fit(X, y)
print(reg.coef_)

Which of the following options will be the output of the given code?

  1. A

    [-0.02634908 0.01189399 0.0917284 0.08966849]

  2. B

    array([-0.22622766, -0.00582008, -0.1820344 , 0.03518086, -0.14490955])

  3. C

    array([-0.22622766, -0.00582008, -0.1820344 ])

  4. D

    Given code will return an error because the data set is not given

Show answer

Correct answer

  • A

    [-0.02634908 0.01189399 0.0917284 0.08966849]

Question 20

+3 marksOne correct option

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

python
import numpy as np
from sklearn.linear_model import SGDRegressor
from sklearn.pipeline import make_pipeline
n_samples, n_features = 18, 4
rng = np.random.RandomState(0)
y = rng.randn(n_samples)
X = rng.randn(n_samples, n_features)
reg = SGDRegressor(max_iter=1000,tol=1e-3,eta0= 0.04, power_t=5,
n_iter_no_change=3, validation_fraction=0.3 ,random_state=42)
reg.fit(X, y)
print(reg.coef_)

Which of the following could be the possible output of print(reg.score())?

  1. A

    -0.528

  2. B

    1

  3. C

    0.528

  4. D

    Given code will return an error

Show answer

Correct answer

  • D

    Given code will return an error