Question 1
Which of the following vectorizer techniques can help to convert a large collection of text documents to a matrix?
CountVectorizer
HashingVectorizer
Both CountVectorizer and HashingVectorizer
None of these

The IIT Madras BS Machine Learning Practice (MLP) Quiz 2 paper sat on 10 Jul 2022, in the May 2022 term: 21 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.
Which of the following vectorizer techniques can help to convert a large collection of text documents to a matrix?
CountVectorizer
HashingVectorizer
Both CountVectorizer and HashingVectorizer
None of these
Correct answer
HashingVectorizer
Correct answer
0.0
1.0
-1.0
0.5
Correct answer
1.0
Which of the options below represent the correct method to preprocess class labels in multi-class setup?
Correct answer
Which of the following options will be the output of the following code block?
from sklearn.feature_extraction.text import TfidfVectorizercorpus = [ 'This is the first document.', 'And is this the second one?', ]vectorizer = TfidfVectorizer()X = vectorizer.fit_transform(corpus)vectorizer.get_feature_names_out()Correct answer
0.65
0.73
0.37
None of these
Correct answer
0.73
Rakesh is solving a regression problem with a KNN model. He has considered k = 3 for his model. Based on the graph shown below, what would you suggest him out of the following options?
His model is suffering from overfitting. So, he should increase the value of k.
His model is suffering from underfitting. So, he should increase the value of k.
His model is suffering from overfitting. So, he should decrease the value of k.
His model is suffering from underfitting. So, he should decrease the value of k.
No suggestions, Rakesh has already chosen the best value of k.
Correct answer
His model is suffering from overfitting. So, he should increase the value of k.
l1 penalty in LinearSVC classifier leads to coef_vectors which are-
dense.
sparse.
Unique class labels.
l1 penalty can’t be set via a parameter in LinearSVC.
Correct answer
sparse.
1
0
0.5
0.40
Correct answer
0.5
Correct answer
The classifier shown in ‘Curve B’ is better than the other two classifiers.
The classifier shown in ‘Curve A’ is better than the other two classifiers.
The classifier shown in ‘Curve C’ is better than the other two classifiers.
All 3 curves demonstrate 3 classifiers of the same quality.
Correct answer
The classifier shown in ‘Curve A’ is better than the other two classifiers.
For a text classification task, which one of the following code snippets will be better suitable than the others?
Correct answer
Which of the following will be the correct output of the code snippet given below?
from sklearn.neighbors import KNeighborsClassifierX = [[2,3], [5,6], [10,11], [15,16],[20,21]]y = [0, 0, 1, 1, 2]neigh = KNeighborsClassifier(n_neighbors=3)neigh.fit(X, y)print(neigh.predict([[8,9]]))0
1
2
None
Correct answer
0
What is the output of the following block of code?
import numpy as npfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerX = np.array([[2, 4], [4, 2]])y = np.array([-1, 1])from sklearn.svm import SVCclf = make_pipeline(StandardScaler(), SVC(kernel='linear'))clf.fit(X, y)print(clf.predict([[-2,2]]))Correct answer
Consider the following code snippet and mark the correct output.
from sklearn.svm import SVCimport numpy as npX = np.array([[-1, -1], [-2, -2], [1, 1], [2, 2]])y = np.array([-1, -1, 1, 1])clf = SVC(kernel='linear')clf.fit(X, y)print(clf.n_support_)Correct answer
Which of the following code blocks will correctly train a large scale regression model using partial_fit, if shape of X_train,Y_train are given as (8000,900,10) and (8000,900) respectively. Note that the dataset has been transformed into batches of size 900 each?
Correct answers
Correct answer: 6
Calculate the precision value (up to 3 decimal places) from the confusion matrix.
Correct answer: 0.975 (accepted within ±0.005)
Calculate the recall value (up to 3 decimal places) from the confusion matrix.
Correct answer: 0.93 (accepted within ±0.005)
What is the output that Prashant will get?
Indices of support vectors.
Number of support vectors.
Weights assigned to the features when kernel=”linear”
ndarray of support vectors.
Correct answer
ndarray of support vectors.
Correct answer: 4