uiz Space

September 2025 term · Machine Learning Practice · BSCS2008

Machine Learning Practice End Term: 21 December 2025 (September 2025 term)

The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 21 Dec 2025, in the September 2025 term: 60 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.

Questions
60
Marks
100
Duration
180 min
MCQ
34
MSQ
9
Written
17

Updated

Official paper: Machine Learning Practice 18 Dec 25 · No negative marking.

Question 1

+2 marksOne correct option

The adfuller() function in statsmodels is used to test:

  1. A

    Whether a time series has seasonal patterns

  2. B

    Whether a time series is stationary

  3. C

    Whether the data follows a normal distribution

  4. D

    Whether the variance of the data changes over time

Show answer

Correct answer

  • B

    Whether a time series is stationary

Question 2

+1 markOne correct option

Identify the errors in the following code:

Identify the errors in the following code:
  1. A

    include_bias has to be kept true for polynomial features.

  2. B

    MinMaxScalar should be used for simple LinearRegression Models

  3. C

    model.fit_transform should be replace with model.fit

  4. D

    model.predict should be replaced with model.predict_proba

Show answer

Correct answer

  • C

    model.fit_transform should be replace with model.fit

Question 3

+2 marksOne correct option

What will typically happen if series_with_nans contains NaNs (null values) ?

What will typically happen if series_with_nans contains NaNs (null values) ?
  1. A

    statsmodels will automatically impute NaNs and fit silently.

  2. B

    fit() will raise an error or drop NaNs depending on the estimator; user should handle NaNs beforehand.

  3. C

    NaNs are treated as zeros.

  4. D

    The model will only use the NaN values to estimate variance.

Show answer

Correct answer

  • B

    fit() will raise an error or drop NaNs depending on the estimator; user should handle NaNs beforehand.

Question 4

+1 markOne correct option

You are using a ColumnTransformer to preprocess a dataset before training a model:

What will be the shape of the transformed matrix X?

You are using a ColumnTransformer to preprocess a dataset before training a model:
  1. A

    (3,2)

  2. B

    (3,3)

  3. C

    (3,4)

  4. D

    (4,3)

Show answer

Correct answer

  • B

    (3,3)

Question 5

+1 markOne correct option

A newly launched movie has no ratings, but metadata such as genre, cast, and director is available. Which algorithm can still recommend it?

  1. A

    User-based Collaborative Filtering

  2. B

    Item-based Collaborative Filtering

  3. C

    Content-based filtering

  4. D

    Matrix factorization without regularization

Show answer

Correct answer

  • C

    Content-based filtering

Question 6

+1 markOne or more correct options

We use classification report to evaluate our classification model:

Which of the following metrics are included in the classification report?

We use classification report to evaluate our classification model:

Select all that apply.

  1. A

    Accuracy

  2. B

    Mean Squared Error

  3. C

    F1 Score

  4. D

    Cross Entropy Loss

  5. E

    Recall

Show answer

Correct answers

  • A

    Accuracy

  • C

    F1 Score

  • E

    Recall

Question 7

+2 marksOne correct option

Performing singular value decomposition on a user-item matrix aims to:

  1. A

    Increase sparsity

  2. B

    Reduce dimensionality

  3. C

    Delete user history

  4. D

    Improve data imbalance

Show answer

Correct answer

  • B

    Reduce dimensionality

Question 8

+1 markOne correct option

Consider the following cases for splitting train and test data for some real world dataset.

Which of the following hold true?

Consider the following cases for splitting train and test data for some real world dataset.
  1. A

    The selected samples(rows) in X_train will always be same for all the cases.

  2. B

    The selected samples(rows) in X_train will always be different for all the cases.

  3. C

    The selected samples(rows) in X_train will always be same for case 1 and case 3.

  4. D

    The selected samples(rows) in X_train will always be same for case 2 and case 3.

Show answer

Correct answer

  • C

    The selected samples(rows) in X_train will always be same for case 1 and case 3.

Question 9

+2 marksOne correct option

Which of the following can be used to evaluate the outputs of the KNNClassifier?

  1. A

    Negative Mean Absolute Error

  2. B

    Silhoutte Score

  3. C

    F1 Score

  4. D

    R2 Score

  5. E

    Inertia

Show answer

Correct answer

  • C

    F1 Score

Question 10

+2 marksWritten answer

What is the output of the following code? (Round to 2 decimals)

What is the output of the following code? (Round to 2 decimals)
Show answer

A written answer, not marked automatically.

Question 11

+2 marksWritten answer

What is the output of the following standard scaler transformation?

What is the output of the following standard scaler transformation?
Show answer

A written answer, not marked automatically.

Question 12

+2 marksWritten answer
Figure from the original question paper
Show answer

A written answer, not marked automatically.

Question 13

+1 markWritten answer

What is the value of recall score computed in the following code? (Enter upto 2 decimals)

What is the value of recall score computed in the following code? (Enter upto 2 decimals)
Show answer

A written answer, not marked automatically.

Question 14

+2 marksOne correct option

You are given the following DataFrame:

You want to perform the following imputation strategy: • Age → Replace missing values with the mean Age of each Department • Salary → Replace missing values with the median Salary of the entire column • Department → No imputation Which of the following code snippets correctly performs the above imputation?

You are given the following DataFrame:
  1. A
    Figure from the original question paper
  2. B
    Figure from the original question paper
  3. C
    Figure from the original question paper
  4. D
    Figure from the original question paper
Show answer

Correct answer

  • C
    Figure from the original question paper

Question 15

+2 marksOne correct option

Which of the following algorithms don't get impacted by feature scaling?

  1. A

    LinearRegression

  2. B

    KNN

  3. C

    KMeans

  4. D

    DecisionTree

Show answer

Correct answer

  • D

    DecisionTree

Question 16

+2 marksWritten answer

You are given the following dataset and model:

What is the value of prediction after running this code?

You are given the following dataset and model:
Show answer

A written answer, not marked automatically.

Question 17

+2 marksWritten answer

Consider the following data preprocessing code. What are the number of zero(s) in the transformed labels vector after applying label encoding?

Consider the following data preprocessing code. What are the number of zero(s) in the transformed labels vector after ap
Show answer

A written answer, not marked automatically.

Question 18

+2 marksOne or more correct options

Select the correct statements from the following regarding GridSearchCV:

Select all that apply.

  1. A

    best_score parameter of grid search returns the mean cross validated score of all the cross validation folds.

  2. B

    best_score parameter of grid search returns the max cross validated score of all the cross validation folds.

  3. C

    If there are 2 parameter sets A and B with A having 3 values and B having 4 values the total parameter combinations grid search will try is 7.

  4. D

    If there are 2 parameter sets A and B with A having 3 values and B having 4 values the total parameter combinations grid search will try is 12.

  5. E

    No other scoring metric other than R2 score and mean_squared_error can be used as the scoring metric for GridSearchCV in case of regression problems.

Show answer

Correct answers

  • A

    best_score parameter of grid search returns the mean cross validated score of all the cross validation folds.

  • D

    If there are 2 parameter sets A and B with A having 3 values and B having 4 values the total parameter combinations grid search will try is 12.

Question 19

+1 markOne correct option

What does metric in the following code measure?

What does metric in the following code measure?
  1. A

    Accuracy

  2. B

    Precision

  3. C

    Recall

  4. D

    F1_Score

Show answer

Correct answer

  • C

    Recall

Question 20

+2 marksWritten answer

For the given above code calculate the sparcity (% of zeros) in one_hot. Enter your answer in percentage rounded to 2 decimals.

For the given above code calculate the sparcity (% of zeros) in one_hot.  Enter your answer in percentage rounded to 2 d
Show answer

A written answer, not marked automatically.

Question 21

+1 markWritten answer

Compute cosine similarity for the two items which have feature vectors as given below (rounded to 2 decimals).

Show answer

A written answer, not marked automatically.

Question 22

+2 marksOne correct option

You are using make_blobs to generate synthetic data for clustering:

What will the output of the above clustering code?

You are using make_blobs to generate synthetic data for clustering:
  1. A

    One cluster containing all points.

  2. B

    It will raise an error since n_samples is not divisible by centers

  3. C

    Two clusters, but not necessarily equal-sized; distribution of samples per cluster may vary.

  4. D

    Two clusters with exactly 4 points each.

Show answer

Correct answer

  • D

    Two clusters with exactly 4 points each.

Question 23

+2 marksOne correct option

Identify the datatypes of the two datasets given below: (Assume all library imports are correctly done)

Identify the datatypes of the two datasets given below: (Assume all library imports are correctly done)
  1. A

    bunch , bunch

  2. B

    bunch , dataframe

  3. C

    dataframe , bunch

  4. D

    series, dataframe

Show answer

Correct answer

  • B

    bunch , dataframe

Question 24

+2 marksOne correct option

What does metric in the following code measure?

What does metric in the following code measure?
  1. A

    Accuracy

  2. B

    Precision

  3. C

    Recall

  4. D

    F1_Score

Show answer

Correct answer

  • B

    Precision

Question 25

+1 markOne correct option

Which of the following statements about Hierarchical Agglomerative Clustering is TRUE?

  1. A

    It starts with all data points in a single cluster and recursively splits them.

  2. B

    It requires the number of clusters to be specified before training.

  3. C

    It repeatedly merges the two closest clusters until a stopping condition is met.

  4. D

    It updates cluster centroids after each merge.

Show answer

Correct answer

  • C

    It repeatedly merges the two closest clusters until a stopping condition is met.

Question 26

+2 marksOne correct option

You are training a RandomForestRegressor on a dataset with 20 features and 10,000 samples. Consider the following code:

Which of the following statements is TRUE about how this Random Forest model will behave?

You are training a RandomForestRegressor on a dataset with 20 features and 10,000 samples.  Consider the following code:
  1. A

    With bootstrap=True, every tree sees the entire dataset, but the samples are shuffled randomly for each tree.

  2. B

    The forest will use all 20 features for each split, but only 5 trees out of the 200 will be trained on bootstrap samples.

  3. C

    Setting max_features=5 means only 5 trees out of 200 will use feature subsets, while the rest use all features.

  4. D

    Each tree will consider only 5 randomly chosen features when looking for the best split at every node.

Show answer

Correct answer

  • D

    Each tree will consider only 5 randomly chosen features when looking for the best split at every node.

Question 27

+1 markOne correct option

You are using a ColumnTransformer to preprocess a dataset before training a model:

What will be the shape of the transformed matrix X?

You are using a ColumnTransformer to preprocess a dataset before training a model:
  1. A

    (3,2)

  2. B

    (4,4)

  3. C

    (3,4)

  4. D

    (4,3)

Show answer

Correct answer

  • B

    (4,4)

Question 28

+2 marksWritten answer

What will be the output of the following code ? (Round to two decimals)

What will be the output of the following code ? (Round to two decimals)
Show answer

A written answer, not marked automatically.

Question 29

+2 marksWritten answer
Figure from the original question paper
Show answer

A written answer, not marked automatically.

Question 30

+1 markOne correct option

If pval = 0.03 for the following code, which of the option is correct at the 5% level?

If pval = 0.03 for the following code, which of the option is correct at the 5% level?
  1. A

    Series is non-stationary.

  2. B

    Series is stationary.

  3. C

    The series has trend.

  4. D

    The series is noise.

Show answer

Correct answer

  • B

    Series is stationary.

Question 31

+2 marksWritten answer

You are given the following dataset and model:

What is the value of prediction after running this code?

You are given the following dataset and model:
Show answer

A written answer, not marked automatically.

Question 32

+2 marksOne correct option

You are given the following four implementations of cosine similarity in NumPy. Which function correctly computes cosine similarity?

  1. A
    Figure from the original question paper
  2. B
    Figure from the original question paper
  3. C
    Figure from the original question paper
  4. D
    Figure from the original question paper
Show answer

Correct answer

  • C
    Figure from the original question paper

Question 33

+2 marksOne or more correct options

For the RandomForestClassifier select the correct pair(s) of parameter(s) and their explanation(s).

Select all that apply.

  1. A

    n_estimators – Number of trees in the RandomForestClassifier

  2. B

    max_depth – Maximum depth allowed for each decision tree

  3. C

    min_samples_leaf – Controls the maximum number of trees that will be created

  4. D

    bootstrap – Sets the number of features used for splitting at each node

Show answer

Correct answers

  • A

    n_estimators – Number of trees in the RandomForestClassifier

  • B

    max_depth – Maximum depth allowed for each decision tree

Question 34

+1 markOne or more correct options

Which of the following can be used to evaluate the outputs of the K-Means algorithm?

Select all that apply.

  1. A

    Negative Mean Absolute Error

  2. B

    Silhoutte Score

  3. C

    F1 Score

  4. D

    R2 Score

  5. E

    Inertia

Show answer

Correct answers

  • B

    Silhoutte Score

  • E

    Inertia

Question 35

+1 markOne correct option

What is the output of the following code?

What is the output of the following code?
  1. A
    Figure from the original question paper
  2. B
    Figure from the original question paper
  3. C
    Figure from the original question paper
  4. D
    Figure from the original question paper
Show answer

Correct answer

  • A
    Figure from the original question paper

Question 36

+2 marksOne or more correct options

Select the correctly matched pairs of sklearn functions with the use of fit, fit_transform and transform.

Select all that apply.

  1. A

    Learning the weights of logistic regression model on training data - fit_transform

  2. B

    Creating a decision tree on the training data - fit

  3. C

    fitting MinMaxScaler on test data - fit_transform

  4. D

    fitting MinMaxScaler on train data - fit_transform

Show answer

Correct answers

  • B

    Creating a decision tree on the training data - fit

  • D

    fitting MinMaxScaler on train data - fit_transform

Question 37

+2 marksOne correct option

Consider the following code snippet. Assume that all required libraries have been imported correctly.

A practitioner observes that each time the fit() method is called on clf, the model is trained from scratch and the parameters learned in the previous training call are discarded. Which of the following changes should be made so that the model continues training from the previously learned parameters when fit() is called again?

Consider the following code snippet. Assume that all required libraries have been imported correctly.
  1. A

    Set warm_start=True

  2. B

    Combine training data from all training sessions into a single dataset

  3. C

    Set retain_parameters=True

  4. D

    This behavior cannot be changed for Perceptron

Show answer

Correct answer

  • A

    Set warm_start=True

Question 38

+1 markWritten answer

What is the output of the following code?

What is the output of the following code?
Show answer

A written answer, not marked automatically.

Question 39

+1 markOne correct option

Consider the following cases for splitting train and test data for some real world dataset.

Which of the following hold true?

Consider the following cases for splitting train and test data for some real world dataset.
  1. A

    The selected samples(rows) in X_train will always be same for all the cases.

  2. B

    The selected samples(rows) in X_train will always be different for all the cases.

  3. C

    The selected samples(rows) in X_train will always be different for case 1 and case 2.

  4. D

    The selected samples(rows) in X_train will always be different for case 1 and case 3.

Show answer

Correct answer

  • C

    The selected samples(rows) in X_train will always be different for case 1 and case 2.

Question 40

+1 markOne correct option

Following is the code to tune the degree parameter of a polynomial regression model.

What should the blank space contain?

Following is the code to tune the degree parameter of a polynomial regression model.
  1. A

    "degree"

  2. B

    "PolynomialFeatures_degree"

  3. C

    "sgd__degree"

  4. D

    "poly__degree"

Show answer

Correct answer

  • D

    "poly__degree"

Question 41

+2 marksWritten answer

You are performing hyperparameter tuning using GridSearchCV for a machine learning model. The following parameter grid is provided:

How many unique hyperparameter combinations will GridSearchCV evaluate in total?

You are performing hyperparameter tuning using GridSearchCV for a machine learning model. The following parameter grid i
Show answer

A written answer, not marked automatically.

Question 42

+1 markOne or more correct options

Which of the following is a hyper parameter?

Select all that apply.

  1. A

    intercept_ in LinearRegression

  2. B

    degree in PolynomialFeatures

  3. C

    n_neighbors in Ridge

  4. D

    min_samples_split in DecisionTreeClassifier

Show answer

Correct answers

  • B

    degree in PolynomialFeatures

  • D

    min_samples_split in DecisionTreeClassifier

Question 43

+1 markOne correct option

You are using make_blobs to generate synthetic data for clustering:

What will the output of the above clustering show?

You are using make_blobs to generate synthetic data for clustering:
  1. A

    One cluster containing all points.

  2. B

    It will raise an error since n_samples is not divisible by centers

  3. C

    Two clusters, but not necessarily equal-sized; distribution of samples per cluster may vary.

  4. D

    Two clusters with exactly 4 points each.

Show answer

Correct answer

  • D

    Two clusters with exactly 4 points each.

Question 44

+1 markOne correct option

You are using statsmodels to forecast a time series. Which of the following represents the correct sequence of code to define an ARIMA model, train it, and view the results?

  1. A
    Figure from the original question paper
  2. B
    Figure from the original question paper
  3. C
    Figure from the original question paper
  4. D
    Figure from the original question paper
Show answer

Correct answer

  • B
    Figure from the original question paper

Question 45

+2 marksOne correct option

What does the following pandas code do ?

What does the following pandas code do ?
  1. A

    All rows where Age < 18, sorted by Marks, index unchanged.

  2. B

    Only rows where Marks > 60, sorted by Age, and index reset.

  3. C

    All rows sorted first by Marks, then by Age.

  4. D

    Drops the Age column and sorts remaining data.

Show answer

Correct answer

  • B

    Only rows where Marks > 60, sorted by Age, and index reset.

Question 46

+2 marksWritten answer

For a LinearRegression model with equation assume that the noise term . The model parameters satisfy the constraint A LinearRegression model is trained without intercept as shown below:

What is the value of ? Enter your answer rounded to three decimal places

For a LinearRegression model with equation  assume that the noise term  . The model parameters satisfy the constraint  A
Show answer

A written answer, not marked automatically.

Question 47

+2 marksOne correct option

What does the parameter hidden_layer_sizes=(50, 30) represent in both MLPClassifier and MLPRegressor?

  1. A

    50 input features and 30 output units

  2. B

    Two hidden layers with 50 and 30 neurons respectively

  3. C

    50 epochs and 30 batches

  4. D

    50 samples per batch and 30 iterations

Show answer

Correct answer

  • B

    Two hidden layers with 50 and 30 neurons respectively

Question 48

+2 marksOne correct option

Which of the following is required for user-based collaborative filtering?

  1. A

    User–item interaction matrix

  2. B

    Item content features

  3. C

    User features (e.g. age, gender etc.)

  4. D

    Image embeddings

Show answer

Correct answer

  • A

    User–item interaction matrix

Question 49

+1 markOne correct option

What is the role of the alpha=1.0 parameter in the given sklearn code to build a regression model?

What is the role of the alpha=1.0 parameter in the given sklearn code to build a regression model?
  1. A

    It applies L1 regularization and sets some coefficients to zero.

  2. B

    It removes regularization completely and behaves like Linear Regression.

  3. C

    It adds L2 regularization that penalizes large coefficients to prevent overfitting.

  4. D

    It makes the model ignore the intercept term.

Show answer

Correct answer

  • C

    It adds L2 regularization that penalizes large coefficients to prevent overfitting.

Question 50

+2 marksWritten answer

Compute cosine similarity for the two items which have feature vectors as given below(rounded to 2 decimals).

Show answer

A written answer, not marked automatically.

Question 51

+2 marksWritten answer

What is the output of the following code?

What is the output of the following code?
Show answer

A written answer, not marked automatically.

Question 52

+2 marksWritten answer

Consider the following code snippet:

If the shape of X is , what will be the number of features in X_transformed?

Consider the following code snippet:
Show answer

A written answer, not marked automatically.

Question 53

+2 marksOne or more correct options

Which of the following is a hyper parameter?

Select all that apply.

  1. A

    "intercept_" in LinearRegression

  2. B

    "degree" in PolynomialFeatures

  3. C

    "n_neighbors" in KNeighborsClassifier

  4. D

    "max_depth" in DecisionTreeClassifier

Show answer

Correct answers

  • B

    "degree" in PolynomialFeatures

  • C

    "n_neighbors" in KNeighborsClassifier

  • D

    "max_depth" in DecisionTreeClassifier

Question 54

+2 marksOne correct option

Given the following code using BaggingClassifier with KNeighborsClassifier as the base estimator:

Which of the following statements is correct?

Given the following code using BaggingClassifier with KNeighborsClassifier as the base estimator:
  1. A

    Above code uses bootstrapping to generate samples for each base classifier.

  2. B

    model will be tested on out of the bags samples.

  3. C

    Due to weights="distance", each base KNN classifier will treat all neighbors equally in terms of voting power.

  4. D

    The ensemble will consist of 3 base KNN classifiers.

  5. E

    None of these

Show answer

Correct answer

  • E

    None of these

Question 55

+2 marksOne or more correct options

Consider the following code snippet that trains a Decision Tree classifier using scikit-learn:

A node in the trained decision tree is split only if both of the following conditions are satisfied: • The node contains at least min_samples_split samples. • Each child node created after the split contains at least min_samples_leaf samples. Assume node (N) is a non-leaf node being considered for splitting. In which of the following cases will the split at node (N) be allowed?

Consider the following code snippet that trains a Decision Tree classifier using scikit-learn:

Select all that apply.

  1. A

    Node (N) contains 15 samples. After splitting, the left child has 9 samples and the right child has 6 samples.

  2. B

    Node (N) contains 6 samples. After splitting, the left child has 4 samples and the right child has 2 samples.

  3. C

    Node (N) contains 12 samples. After splitting, the left child has 3 samples and the right child has 9 samples.

  4. D

    Node (N) contains 8 samples. After splitting, the left child has 4 samples and the right child has 4 samples.

Show answer

Correct answers

  • A

    Node (N) contains 15 samples. After splitting, the left child has 9 samples and the right child has 6 samples.

  • D

    Node (N) contains 8 samples. After splitting, the left child has 4 samples and the right child has 4 samples.

Question 56

+2 marksOne or more correct options

Which of the following algorithms may get impacted by feature scaling?

Select all that apply.

  1. A

    LinearRegression

  2. B

    DecisionTree

  3. C

    SVM

  4. D

    NaiveBayes

Show answer

Correct answers

  • A

    LinearRegression

  • C

    SVM

Question 57

+2 marksOne correct option

Consider the following ensemble model built using VotingClassifier with voting='soft':

How is the final prediction for a test sample obtained?

Consider the following ensemble model built using VotingClassifier with voting='soft':
  1. A

    By selecting the most common predicted class.

  2. B

    By averaging predicted class probabilities.

  3. C

    By summing the predicted class labels.

  4. D

    By choosing the most accurate classifier.

Show answer

Correct answer

  • B

    By averaging predicted class probabilities.

Question 58

+2 marksOne correct option

Given below a y_train list which consists of coffee order's preference by the customers in a cafe.

MultiLabelBinarizer from sklearn library has been used to convert the y_train into numbers, so which of the following option matches with the output of the following code ?

Given below a y_train list which consists of coffee order's preference by the customers in a cafe.
Given below a y_train list which consists of coffee order's preference by the customers in a cafe.
  1. A

    [[1 0 1 0],[1 0 0 1],[0 1 0 1],[0 1 1 0]]

  2. B

    [[0 0],[1 0],[0 1],[1 1],[1 0],[0 0],[0 0],[0 0]]

  3. C

    [[1 0 1 0 0 1 0 0],[1 0 0 1 1 0 0 0]]

  4. D

    [[1 0][1 0],[1 0] [0 1],[0 1] [0 1],[0 1][1 0]]

Show answer

Correct answer

  • A

    [[1 0 1 0],[1 0 0 1],[0 1 0 1],[0 1 1 0]]

Question 59

+2 marksOne correct option

You are given a dataset where each row represents a customer using two numerical features. You apply K-means clustering with K=3 clusters using the following code:

What does the variable labels represent after the model is fitted?

You are given a dataset where each row represents a customer using two numerical features. You apply K-means clustering
  1. A

    The values of the input features used for clustering.

  2. B

    The cluster index assigned to each data point.

  3. C

    The total number of clusters formed.

  4. D

    The coordinates of the cluster centroids.

Show answer

Correct answer

  • B

    The cluster index assigned to each data point.

Question 60

+2 marksOne correct option

What could be the output for below code

What could be the output for below code
  1. A

    ['document' 'first' 'is' 'second' 'the' 'this']

  2. B

    {'this': 5, 'is': 2, 'the': 4, 'first': 1, 'document': 0, 'second': 3}

  3. C

    [5, 2, 4, 1, 0, 3]

  4. D
    Figure from the original question paper
Show answer

Correct answer

  • B

    {'this': 5, 'is': 2, 'the': 4, 'first': 1, 'document': 0, 'second': 3}