Quiz Space

MLP Quiz 2: 3 December 2023 (September 2023 term)

Question 1

+1 markOne correct option

You are working with a dataset containing 1000 samples, aiming to classify them using the KNeighborsClassifier from scikit-learn. After trying an initial configuration, you observe that the model seems to be overfitting, with the following accuracies:

python
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score
# Initial Configuration
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train, y_train)
train_acc = accuracy_score(y_train, knn.predict(X_train))
val_acc = accuracy_score(y_val, knn.predict(X_val))
  • Training accuracy: 98%
  • Validation accuracy: 65%

After observing such performance of the model, Which of the following values for n_neighbors would be more suitable to try next?

  1. A

    1

  2. B

    2

  3. C

    10

  4. D

    500

Question 2

+1 markOne correct option

Consider the following code segment which uses CountVectorizer on a set of documents:

python
from sklearn.feature_extraction.text import CountVectorizer
documents = [
'apple orange banana',
'apple apple',
'banana orange',
'apple banana orange orange'
]
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(documents)

After executing the code, what will be the shape of matrix X?

  1. A

    (4, 3)

  2. B

    (3, 4)

  3. C

    (4, 4)

  4. D

    (3, 3)

Question 3

+2 marksOne correct option

Assume train data (X_train, y_train) and test data (X_test) is given as numpy array and you build and train a LogisticRegression model. Which of the following options might possibly be the predicted class of first two samples(rows) of the test data according to the code given below?

python
>>> from sklearn.linear_model import LogisticRegression
>>> log_reg = LogisticRegression()
>>> log_reg.fit(X_train,y_train)
>>> print(log_reg.classes_)
[0,1,2] #output of above code
>>> print(log_reg.predict_proba(X_test[[0]]))
[[2.73e-45, 1.21e-51, 1.00e+00]] #output of above code
>>> print(log_reg.predict_proba(X_test[[1]]))
[[7.09e-29, 1.00e+00, 2.02e-36]] #output of above code
>>> print(log_reg.predict(X_test[0:2]))
  1. A
  2. B
  3. C
  4. D

20 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the MLP Quiz 2 3 Dec 2023 paper

The IIT Madras BS Machine Learning Practice (MLP) Quiz 2 paper sat on 3 Dec 2023, in the September 2023 term: 23 questions for 50 marks in 120 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureMLP Quiz 2 3 Dec 2023 at a glance
TermSeptember 2023 term
SubjectMachine Learning Practice
Course codeBSCS2008
Questions23
Marks50
Duration120 min
MCQ13
MSQ8
Numerical2
Official paperIIT M DIPLOMA AN2 EXAM QDD2 03 Dec 2023
Negative markingNo negative marking.
Updated

Same Quiz 2, other subjects

More MLP