Question 1
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.
20 - 40
80 above
Less than 20
40-60

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.
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.
20 - 40
80 above
Less than 20
40-60
Correct answer
20 - 40
Which of the following Sklearn objects can help you to reduce, expand or generate feature representations?
Estimator
Predictor
Transformer
None of these
Correct answer
Transformer
What will be the output of the following code?
Correct answer
Go through the code snippet given below:
What will be the shape of the feature matrix (X.shape) and the label vector (y.shape)?
(2000, 12) and (1000, 6)
(1, 1000) and (1,1000)
(599, 1) and (699, 1)
(1000, 6) and (1000,)
Correct answer
(1000, 6) and (1000,)
Which of the following options is likely to be the correct output of the code snippet given below?
Correct answer
In the figure 1, what are the names of classes arranged in the increasing order of the median values?
First < Second < Third
Third < Second < First
Second < Third < First
Third < First < Second
Correct answer
Third < Second < First
Go through the code snippet given below and mark the correct output.
1
3
9
25
4
5
Correct answer
5
Which of the following is likely to be the correct output of the code given below?
12
29
No evaluation metrics are mentioned, hence it will produce an error
0.96
Correct answer
0.96
Which of the following is likely to be the correct output of the code given below?
from math import nanimport numpy as npfrom sklearn.impute import SimpleImputerdata=[(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)Correct answer
Consider the following code snippet:
Which of the following could be the correct output?
Correct answer
Which of the following options will be the correct output of print(clf.coef_)?
[ 0.35 -0. -0. ]
[-0.85,0]
[3,2,1,2]
Given code block will return an error.
Correct answer
[ 0.35 -0. -0. ]
Go through the code snippet given below and mark the correct output.
0.61
0.83
0.95
1
-0.6
5
Correct answer
0.95
Which of the following is likely to be the correct output of the code given below?
Correct answer
Which of the following code blocks will correctly take the learning rate as‘optimal’ ?
Correct answer
Which of the following code blocks will correctly return an array of feature variables?
Correct answers
Scikit-Learn’s API is remarkably well designed. The main design principles are:-
Nonproliferation of classes
Sensible defaults
Consistency
Proportion
Correct answers
Nonproliferation of classes
Sensible defaults
Consistency
Go through the code block given below:
from sklearn.preprocessing import PolynomialFeaturesfrom sklearn.pipeline import Pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.linear_model import RidgeCVfrom sklearn.datasets import load_diabetesdiabetes = load_diabetes(as_frame=True)train_X= diabetes.datatrain_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?
0.0
0.01
0.1
1
Correct answers
0.01
0.1
1
Enter the correct output of the following code block.
import numpy as npfrom sklearn.model_selection import ShuffleSplitX = 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=1for i,j in rs.split(X): k+=1print(k)Correct answer: 6
Go through the code snippet given below and answer the given subquestions.
import numpy as npfrom sklearn.linear_model import SGDRegressorfrom sklearn.pipeline import make_pipelinen_samples, n_features = 18, 4rng = 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?
[-0.02634908 0.01189399 0.0917284 0.08966849]
array([-0.22622766, -0.00582008, -0.1820344 , 0.03518086, -0.14490955])
array([-0.22622766, -0.00582008, -0.1820344 ])
Given code will return an error because the data set is not given
Correct answer
[-0.02634908 0.01189399 0.0917284 0.08966849]
Go through the code snippet given below and answer the given subquestions.
import numpy as npfrom sklearn.linear_model import SGDRegressorfrom sklearn.pipeline import make_pipelinen_samples, n_features = 18, 4rng = 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())?
-0.528
1
0.528
Given code will return an error
Correct answer
Given code will return an error