Question 1
What will be the shape of X and y?
(120,90) and (120,)
(120,10) and (120,)
(90,120) and (90,)
(90,10) and (90,)
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.
What will be the shape of X and y?
(120,90) and (120,)
(120,10) and (120,)
(90,120) and (90,)
(90,10) and (90,)
Correct answer
(120,90) and (120,)
What will be the shape of the feature matrix (X.shape) and the label vector (y.shape) for the following block of code?
(699, 1) and (599, 1)
(500, 1) and (500, 1)
(1, 500) and (1,500)
(599, 1) and (699, 1)
Correct answer
(500, 1) and (500, 1)
What will be the output of the following code?
from sklearn.datasets import load_wineone = 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))Bunch, Tuple, DataFrame, DataFrame
Bunch, Tuple, DataFrame, Tuple
Bunch, Bunch, Bunch, Bunch
DataFrame, DataFrame, DataFrame, DataFrame
Bunch, Ndarray, Bunch, Ndarray
It will result into an error.
Correct answer
Bunch, Bunch, Bunch, Bunch
Consider following code snippet:
Above classifier uses:
hinge but quadratically penalized.
logistic regression.
linear SVM.
None of these.
perceptron.
Correct answer
linear SVM.
Which of the following Naive Bayes algorithms can be applied if the data has discrete features that are categorically distributed?
GaussianNB
CategoricalNB
ComplementNB
None of these
Correct answer
CategoricalNB
Which of the following options represents the correct output of the following block of code?
[0]
[2]
[1.5]
[1]
Correct answer
[2]
Which of the following estimators implement partial_fit method in Regression?
Ridge Regression
SGDRegressor
Linear Regression
Polynomial Regression
Correct answer
SGDRegressor
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.
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 is correct but statement 2 is incorrect.
Which of the following options represents the correct value of gamma for SVC_classifier = SVC(gamma = ’auto’)?
Correct answer
Consider the following scatter plots of four different input datasets:
Which data will be classified better using gaussian rbf kernel?
Data 1
Data 3
Data 4
Data 2
Correct answer
Data 1
When a node is split further in a decision tree:
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.
Which of the following is/are Correct for K-means algorithm.
The algorithm is sensitive to outliers.
It terminates at a local optimum if SSE is used.
k-means is considered to be a linear algorithm.
All of these
Correct answer
All of these
Hierarchical Clustering can also be called:
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?
CountVectorizer does not store vocabulary, its object takes less space compared to HashingVectorizer
HashingVectorizer does not store vocabulary, its object takes less space compared to CountVectorizer
CountVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
Correct answers
CountVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
HashingVectorizer alleviates any dependence with function calls performed on the previous chunk of data in case of incremental learning
Which of the following statements correctly set L1 penalty to 0.2 and L2 Penalty to 0.8 in LogisticRegression?
Correct answer
Which of the following are hyper parameters in a decision tree?
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
Which of the following statements are incorrect about the AUC?
The ROC curve plots sensitivity (recall) on the x-axis against specificity on the y- axis
A completely effective classifier is a diagonal line, and it will have an AUC of 0.5.
The larger the value of AUC, the less 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 answers
The ROC curve plots sensitivity (recall) on the x-axis against specificity on the y- axis
The larger the value of AUC, the less effective the classifier.
The output of the following block of code will be:
Correct answer: 4
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 | juli | 22 | 84 | 78 |
| 1 | nick | 51 | 76 | 61 |
| 2 | tom | 41 | 76 | 81 |
| 3 | Abhi | 56 | 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: 23 (accepted within ±0.05)
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: 4
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.833 , Recall: 0.875, Accuracy: 0.833
Precision: 0.875, Recall: 0.833, Accuracy: 0.833
Precision: 0.9783, Recall: 0.9281, Accuracy: 0.909
None of these
Correct answer
Precision: 0.833 , Recall: 0.875, Accuracy: 0.833
Consider the following code snippet:
which of the following could be the correct output?
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.], [1., 2., 1., 4., 2., 1.]])
Which of the following is likely to be the correct output of the code given below?
[0.95238095, 0. ]
[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.95238095, 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.82
Correct answer
0.82
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.‘
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 is correct but statement 2 is incorrect.
Which of the following options represents the correct option to set the regularization rate in RidgeClassifier?
Correct answer
Which of the following options represents the correct output for the following block of code?
(11, 1)
(1, 10)
(1, 11)
(10, 1)
Correct answer
(1, 10)
Which of the following options represents the correct output for the following block of code?
array([, ’is’, ’name’, ’the’], dtype=object)
array([’bond’, ’is’, ’james’, ’name’, ’the’,’ !’], dtype=object)
array([’bond’, ’bond’, ’is’, ’james’, ’name’, ’the’], dtype=object)
array([’bond’, ’is’, ’james’, ’name’, ’the’], dtype=object)
Correct answer
array([’bond’, ’is’, ’james’, ’name’, ’the’], 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([2])
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:
2, 3
1, 3, 5
3, 5
2, 4
1, 3, 4
1, 2, 4
Correct answer
2, 3
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.]
Correct answer
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?
Perform one hot encoding followed by training with LogisticRegression model (sklearn.linear_model).
Perform standard scaling followed by a
sklearn.neighbors.KNeighborsClassifier model.
Perform min-max scaling followed by a sklearn.tree.DecisionTreeClassifier model.
Perform max-absolute scaling followed by a
sklearn.linear_model.SGDClassifier model.
Correct answer
Perform max-absolute scaling followed by a
sklearn.linear_model.SGDClassifier model.
Let data-set has 784 features and the trained using the following code:
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:
w = mlp_clf.coefs_w = np.array(w[0])w.shape(784, 100)
(784, 1)
(1, 784)
(100, 784)
Correct answer
(784, 100)
Which of the following options represents the correct output of the following block of code?
1
0
0.110
0.223
0.533
Correct answer
0.223
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.]
Correct answer
Go through the code snippet given below and answer the 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.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.
0.055
0.05
0.905
0.1
1
Correct answers
0.055
0.905
Go through the code snippet given below and answer the 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.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
-2999.79
0.528
0.681
Correct answer
-2999.79