Question 1
We wish to load digit dataset from sklearn. Which of the following will result into an error?
The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 11 Dec 2022, in the September 2022 term, set ETD1-2: 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.
We wish to load digit dataset from sklearn. Which of the following will result into an error?
Correct answer
Which of the following statements is/are incorrect about the AUC?
AUC stands for Area Underneath the Curve.
A completely effective classifier is a diagonal line, and it will have an AUC of 0.5.
The larger the value of AUC, the more effective the classifier.
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.
None of these.
Correct answer
A completely effective classifier is a diagonal line, and it will have an AUC of 0.5.
Which of the following options represents the correct option to set the regularization rate in RidgeClassifier?
Correct answer
Putting loss=hinge in class sklearn.linear_model.SGDClassifier(loss=’hinge’) dictates which of the following loss functions in SGDClassifier?
hinge but quadratically penalized
logistic regression
linear SVM
None of these
Correct answer
linear SVM
Which of the following Naive Bayes algorithms can be applied if the data is imbalanced?
GaussianNB
ComplementNB
CategoricalNB
None of these
Correct answer
ComplementNB
Which of the following options represents the correct output for the following block of code?
[0.]
[0.5]
[1.5]
[1.]
Correct answer
[1.]
Mention which of the following statement(s) is / are correct?
1. 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.
2. Statement 2: Sklearn can process large data in batches and updates the model parameters for each batch.
Statement 1 is correct but statement 2 is incorrect.
Statement 1 is incorrect but statement 2 is correct.
Statement 1 and statement 2 both are incorrect.
Statement 1 and statement 2 both are correct.
Correct answer
Statement 1 and statement 2 both are correct.
Which of the following options implements largest measure of regularization, i.e. which of these models will have lowest overfitting?
Correct answer
Consider the following scatter plots of four different input datasets:
Which data will be classified better using gaussian rbf kernel?
Data 4
Data 3
Data 1
Data 2
Correct answer
Data 1
Consider following statements regarding a decision tree model:
1. It is a non-parametric model.
2. It has a tendency to underfit if allowed to grow unconditionally.
3. It can be used for regression and classification problems only, but not for clustering. 4. It is one of the most difficult machine learning models to interpret.
5. For regression problems, decision tree’s loss function and evaluation metric can be same. Choose the option with all the correct statements:
1, 3, 5
1, 3
3, 5
2, 4
1, 3, 4
1, 2, 4
Correct answer
1, 3, 5
When a node is split in a decision tree (in sklearn):
It creates only two new children nodes always.
It can create two or more new children nodes always.
It depends on the cardinality of the categorical feature.
It depends on the scale of the numerical feature.
Correct answer
It creates only two new children nodes always.
Consider following statements:
1. The K-means algorithm aims to choose centroids that minimise the inertia.
2. The K-Means algorithm requires the number of clusters to be specified
Choose the correct option of the following:
Both statement 1 and 2 are correct.
Statement 1 is correct but statement 2 is incorrect.
Statement 1 is incorrect but statement 2 is correct.
Both statement 1 and 2 are incorrect.
Correct answer
Both statement 1 and 2 are correct.
Hierarchical Clustering can also be called as
Centroid Based Clustering
Distribution-based Clustering
Density-based Clustering
Connectivity-Based Clustering
Correct answer
Connectivity-Based Clustering
Which of the following options represents the major difference between HashingVectorizer and CountVectorizer?
HashingVectorizer does not store vocabulary, its object takes less space compared to CountVectorizer
CountVectorizer does not store vocabulary, its object takes less space compared to HashingVectorizer
HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
CountVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
Correct answers
HashingVectorizer does not store vocabulary, its object takes less space compared to CountVectorizer
HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
The partial_fit in sklearn’s Perceptron model helps to:
Iteratively train the model over a large dataset
Implement batch gradient descent
Update half of the weight parameters in each epoch.
Tracking progress of the model in each iteration.
Correct answers
Iteratively train the model over a large dataset
Implement batch gradient descent
Tracking progress of the model in each iteration.
Correct answers
Which of the following are hyper parameters in a decision tree in sklearn?
Number of features
Number of minimum samples to split
Height of the tree
Diameter of the tree
Correct answers
Number of minimum samples to split
Height of the tree
Enter the output (up to 2 decimal points) for the following block of code.
Correct answer: 12 (accepted within ±0.05)
Consider the following code snippet:
array([[1., 2., 1., 4., 2., 1.], [1., 2., 1., 4., 2., 1.]])
array([[1., 2., 1., 4., 2., 1., 4., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 4., 4., 2., 1.]])
array([[1., 2., 1., 2.], [1., 2., 1., 2.]])
array([[1., 2., 1., 4., 2., 1., 8., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 8., 4., 2., 1.]])
Correct answer
array([[1., 2., 1., 4., 2., 1., 8., 4., 2., 1.], [1., 2., 1., 4., 2., 1., 8., 4., 2., 1.]])
Which of the following is likely to be the correct output of the code given below?
[0.85,0.1,0.05]
[2,3,1]
[0.85,0]
There are some mistakes in the 3rd /4th line of code, hence it will produce error.
Correct answer
[0.85,0]
Which of the following is likely to be the correct output of the code given below?
5
99
Given code will produce an error
0.96
Correct answer
Given code will produce an error
The correct code block or blocks to set adaptive learning rate while using SGDRegressor will be:
Correct answer
Consider following statements:
1. Statement 1 : In order to extend ROC curve and ROC area to multi-label classification, it is necessary to binarize the output.
2. Statement 2: In SGDClassifier, setting warm_start=True retains the weight values of the model after max_iter and hence produce different results for each execution.
Choose the correct option:
Statement 1 is correct but statement 2 is incorrect.
Statement 1 is incorrect but statement 2 is correct.
Statement 1 and statement 2 both are incorrect.
Statement 1 and statement 2 both are correct.
Correct answer
Statement 1 and statement 2 both are correct.
Which of the following options represents the correct output for the following block of code?
(11, 1)
(1, 11)
(10, 1)
(1, 10)
Correct answer
(1, 10)
Which of the following options represents the correct output for the following block of code?
array([’is’, ’sparta’, ’this’], dtype=object)
array([’is’, ’sparta’, ’this’,’ !’], dtype=object)
array([ ’sparta’, ’this’,’ !’], dtype=object)
array([’sparta’], dtype=object)
Correct answer
array([’is’, ’sparta’, ’this’], dtype=object)
Which of the following options represents the correct output of the following block of code?
array([2])
array([1.5])
array([1])
array([0])
Correct answer
array([1])
You have a regression problem to solve with following information:
1. All features are numerical.
2. The dataset has size of 40 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?
Perform one hot encoding followed by training with LinearRegression model (from sklearn.linear_model).
Perform standard scaling followed by training with KNeighborsRegressor model (from sklearn.neighbors).
Perform min-max scaling followed by training with DecisionTreeRegressor model (from sklearn.tree).
Perform min-max scaling followed by training with SGDRegressor model (from sklearn.linear_model).
Correct answer
Perform min-max scaling followed by training with SGDRegressor model (from sklearn.linear_model).
Consider the following code and select the correct options.
(Note: Assume necessary imports.)
Scaled data have values in between [0, 1].
Regressor has three hidden layers.
Regressor has 150 hidden layers.
Regressor applies stochastic gradient decent to update the weights.
Correct answers
Regressor has three hidden layers.
Regressor applies stochastic gradient decent to update the weights.
Refer the dataframe(df) given below and enter the correct output (up to 2 decimal points) for the following block of code:
| Name | Assignment-1 | Assignment-2 | Assignment-3 | |
|---|---|---|---|---|
| 0 | tom | 52 | 84 | 78 |
| 1 | nick | 51 | 76 | 81 |
| 2 | juli | 41 | 76 | 81 |
| 3 | Abhi | 62 | 67 | 82 |
| 4 | Krish | 51 | 72 | 84 |
Figure 2: Sample dataframe
import pandas as pdimport numpy as npdf['total'] = df['Assignment-1']+df['Assignment-2']+df['Assignment-3']print(df['total'].max()-df["total"].min())Correct answer: 16 (accepted within ±0.05)
The output of the following block of code will be:
Correct answer: 6
Enter the output (up to 2 decimal points) for the following block of code.
Correct answer: 0.75
What is the correct output of the following block of code?
[Note: LinearSVC implements “one-vs-the-rest” multi-class strategy]
Correct answer: 3
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]
Precision: 0.9783, Recall: 0.9289, Accuracy: 0.9909
Precision: 0.9289, Recall: 0.9783, Accuracy: 0.9909
Precision: 0.9909, Recall: 0.9783, Accuracy: 0.9289
None of these.
Correct answer
Precision: 0.9783, Recall: 0.9289, Accuracy: 0.9909
Which of the following options represents the correct output of the following block of code?
1
0
0.210
0.105
0.233
Correct answer
0.105
Rajesh 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 10 to 20 (both inclusive) at the interval of 1.
3. Cross validation =4.
4. Learning rate must vary between 0.1 to 1.0 (both inclusive) at the intervals of 0.1.
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 Rajesh’s task?
[Note: Assume necessary imports and variables for training and test sets.]
Correct answer
Asha wants to train a bagging classifier with following specifications:
1. Base estimator as k nearest neighbour classifier with default parameter values.
2. 70% of the data is used to create a bag of samples.
3. Create subsets of training set with replacement.
4. Take all features when bootstrapping.
5. Train the model on training set.
6. Print score on test set.
Which of the following code blocks will correctly execute Asha’s task?
[Note: Assume necessary imports and variables for training and test sets.]
Correct answer
Go through the code snippet given below and answer the given subquestions.
from sklearn.preprocessing import PolynomialFeaturesfrom sklearn.pipeline import Pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.linear_model import RidgeCVfrom sklearn.datasets import load_diabetesdataset = load_diabetes(as_frame=True)X=dataset.datay=dataset.target
lf= np.arange(0.01, 1, 0.03)
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.
0.03
0.7
0.01
0.1
1
Correct answers
0.7
0.01
0.1
Go through the code snippet given below and answer the given subquestions.
from sklearn.preprocessing import PolynomialFeaturesfrom sklearn.pipeline import Pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.linear_model import RidgeCVfrom sklearn.datasets import load_diabetesdataset = load_diabetes(as_frame=True)X=dataset.datay=dataset.target
lf= np.arange(0.01, 1, 0.03)
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
-3000.38
0.528
0.681
Correct answer
-3000.38