ML Study Hub

Home / Past papers / MLP End Term / this paper

Machine Learning Practice 18 Dec 25 - 21 Dec 2025

MLP End Term60 questions100 marks33 MCQ · 17 SA · 10 MSQ
Elapsed 00:00
Q1MCQ2 marks
The adfuller() function in statsmodels is used to test:
  1. Whether a time series has seasonal patterns
  2. Whether a time series is stationary
  3. Whether the data follows a normal distribution
  4. Whether the variance of the data changes over time
Q2MCQ2 marks
What will typically happen if series_with_nans contains NaNs (null values) ? question figure
  1. statsmodels will automatically impute NaNs and fit silently.
  2. fit() will raise an error or drop NaNs depending on the estimator; user should handle NaNs beforehand.
  3. NaNs are treated as zeros.
  4. The model will only use the NaN values to estimate variance.
Q3MCQ1 mark
A newly launched movie has no ratings, but metadata such as genre, cast, and director is available. Which algorithm can still recommend it?
  1. User-based Collaborative Filtering
  2. Item-based Collaborative Filtering
  3. Content-based filtering
  4. Matrix factorization without regularization
Q4MCQ2 marks
Performing singular value decomposition on a user-item matrix aims to:
  1. Increase sparsity
  2. Reduce dimensionality
  3. Delete user history
  4. Improve data imbalance
Q5MCQ2 marks
Which of the following can be used to evaluate the outputs of the KNNClassifier?
  1. Negative Mean Absolute Error
  2. Silhoutte Score
  3. F1 Score
  4. R2 Score
  5. Inertia
Q6SA2 marks
What is the output of the following standard scaler transformation? question figure
Q7SA1 mark
What is the value of recall score computed in the following code? (Enter upto 2 decimals) question figure
Q8MSQ2 marksselect all that apply
Which of the following algorithms don't get impacted by feature scaling?
  1. LinearRegression
  2. KNN
  3. KMeans
  4. DecisionTree
Q9SA2 marks
Consider the following data preprocessing code. What are the number of zero(s) in the transformed labels vector after applying label encoding? question figure
Q10MCQ1 mark
What does metric in the following code measure? question figure
  1. Accuracy
  2. Precision
  3. Recall
  4. F1_Score
Q11SA1 mark
Compute cosine similarity for the two items which have feature vectors as given below (rounded to 2 decimals).
Q12MCQ2 marks
Identify the datatypes of the two datasets given below: (Assume all library imports are correctly done) question figure
  1. bunch , bunch
  2. bunch , dataframe
  3. dataframe , bunch
  4. series, dataframe
Q13MCQ1 mark
Which of the following statements about Hierarchical Agglomerative Clustering is TRUE?
  1. It starts with all data points in a single cluster and recursively splits them.
  2. It requires the number of clusters to be specified before training.
  3. It repeatedly merges the two closest clusters until a stopping condition is met.
  4. It updates cluster centroids after each merge.
Q14MCQ1 mark
You are using a ColumnTransformer to preprocess a dataset before training a model: question figure What will be the shape of the transformed matrix X?
  1. (3,2)
  2. (4,4)
  3. (3,4)
  4. (4,3)
Q15SA2 marks
question figure
Q16SA2 marks
You are given the following dataset and model: question figure What is the value of prediction after running this code?
Q17MSQ2 marksselect all that apply
For the RandomForestClassifier select the correct pair(s) of parameter(s) and their explanation(s).
  1. n_estimators – Number of trees in the RandomForestClassifier
  2. max_depth – Maximum depth allowed for each decision tree
  3. min_samples_leaf – Controls the maximum number of trees that will be created
  4. bootstrap – Sets the number of features used for splitting at each node
Q18MCQ1 mark
What is the output of the following code? question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q19MCQ2 marks
Consider the following code snippet. Assume that all required libraries have been imported correctly. question figure 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?
  1. Set warm_start=True
  2. Combine training data from all training sessions into a single dataset
  3. Set retain_parameters=True
  4. This behavior cannot be changed for Perceptron
Q20MCQ1 mark
Consider the following cases for splitting train and test data for some real world dataset. question figure Which of the following hold true?
  1. The selected samples(rows) in X_train will always be same for all the cases.
  2. The selected samples(rows) in X_train will always be different for all the cases.
  3. The selected samples(rows) in X_train will always be different for case 1 and case 2.
  4. The selected samples(rows) in X_train will always be different for case 1 and case 3.
Q21SA2 marks
You are performing hyperparameter tuning using GridSearchCV for a machine learning model. The following parameter grid is provided: question figure How many unique hyperparameter combinations will GridSearchCV evaluate in total?
Q22MCQ1 mark
You are using make_blobs to generate synthetic data for clustering: question figure What will the output of the above clustering show?
  1. One cluster containing all points.
  2. It will raise an error since n_samples is not divisible by centers
  3. Two clusters, but not necessarily equal-sized; distribution of samples per cluster may vary.
  4. Two clusters with exactly 4 points each.
Q23MCQ2 marks
What does the following pandas code do ? question figure
  1. All rows where Age < 18, sorted by Marks, index unchanged.
  2. Only rows where Marks > 60, sorted by Age, and index reset.
  3. All rows sorted first by Marks, then by Age.
  4. Drops the Age column and sorts remaining data.
Q24MCQ2 marks
What does the parameter hidden_layer_sizes=(50, 30) represent in both MLPClassifier and MLPRegressor?
  1. 50 input features and 30 output units
  2. Two hidden layers with 50 and 30 neurons respectively
  3. 50 epochs and 30 batches
  4. 50 samples per batch and 30 iterations
Q25MCQ1 mark
What is the role of the alpha=1.0 parameter in the given sklearn code to build a regression model? question figure
  1. It applies L1 regularization and sets some coefficients to zero.
  2. It removes regularization completely and behaves like Linear Regression.
  3. It adds L2 regularization that penalizes large coefficients to prevent overfitting.
  4. It makes the model ignore the intercept term.
Q26SA2 marks
What is the output of the following code? question figure
Q27MSQ2 marksselect all that apply
Which of the following is a hyper parameter?
  1. "intercept_" in LinearRegression
  2. "degree" in PolynomialFeatures
  3. "n_neighbors" in KNeighborsClassifier
  4. "max_depth" in DecisionTreeClassifier
Q28MSQ2 marksselect all that apply
Consider the following code snippet that trains a Decision Tree classifier using scikit-learn: question figure 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?
  1. Node (N) contains 15 samples. After splitting, the left child has 9 samples and the right child has 6 samples.
  2. Node (N) contains 6 samples. After splitting, the left child has 4 samples and the right child has 2 samples.
  3. Node (N) contains 12 samples. After splitting, the left child has 3 samples and the right child has 9 samples.
  4. Node (N) contains 8 samples. After splitting, the left child has 4 samples and the right child has 4 samples.
Q29MCQ2 marks
Consider the following ensemble model built using VotingClassifier with voting='soft': question figure How is the final prediction for a test sample obtained?
  1. By selecting the most common predicted class.
  2. By averaging predicted class probabilities.
  3. By summing the predicted class labels.
  4. By choosing the most accurate classifier.
Q30MCQ2 marks
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: question figure What does the variable labels represent after the model is fitted?
  1. The values of the input features used for clustering.
  2. The cluster index assigned to each data point.
  3. The total number of clusters formed.
  4. The coordinates of the cluster centroids.
Q31MCQ1 mark
Identify the errors in the following code: question figure
  1. include_bias has to be kept true for polynomial features.
  2. MinMaxScalar should be used for simple LinearRegression Models
  3. model.fit_transform should be replace with model.fit
  4. model.predict should be replaced with model.predict_proba
Q32MCQ1 mark
You are using a ColumnTransformer to preprocess a dataset before training a model: question figure What will be the shape of the transformed matrix X?
  1. (3,2)
  2. (3,3)
  3. (3,4)
  4. (4,3)
Q33MSQ1 markselect all that apply
We use classification report to evaluate our classification model: question figure Which of the following metrics are included in the classification report?
  1. Accuracy
  2. Mean Squared Error
  3. F1 Score
  4. Cross Entropy Loss
  5. Recall
Q34MCQ1 mark
Consider the following cases for splitting train and test data for some real world dataset. question figure Which of the following hold true?
  1. The selected samples(rows) in X_train will always be same for all the cases.
  2. The selected samples(rows) in X_train will always be different for all the cases.
  3. The selected samples(rows) in X_train will always be same for case 1 and case 3.
  4. The selected samples(rows) in X_train will always be same for case 2 and case 3.
Q35SA2 marks
What is the output of the following code? (Round to 2 decimals) question figure
Q36SA2 marks
question figure
Q37MCQ2 marks
You are given the following DataFrame: question figure 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?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q38SA2 marks
You are given the following dataset and model: question figure What is the value of prediction after running this code?
Q39MSQ2 marksselect all that apply
Select the correct statements from the following regarding GridSearchCV:
  1. best_score parameter of grid search returns the mean cross validated score of all the cross validation folds.
  2. best_score parameter of grid search returns the max cross validated score of all the cross validation folds.
  3. 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. 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. 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.
Q40SA2 marks
For the given above code calculate the sparcity (% of zeros) in one_hot. Enter your answer in percentage rounded to 2 decimals. question figure
Q41MCQ2 marks
You are using make_blobs to generate synthetic data for clustering: question figure What will the output of the above clustering code?
  1. One cluster containing all points.
  2. It will raise an error since n_samples is not divisible by centers
  3. Two clusters, but not necessarily equal-sized; distribution of samples per cluster may vary.
  4. Two clusters with exactly 4 points each.
Q42MCQ2 marks
What does metric in the following code measure? question figure
  1. Accuracy
  2. Precision
  3. Recall
  4. F1_Score
Q43MCQ2 marks
You are training a RandomForestRegressor on a dataset with 20 features and 10,000 samples. Consider the following code: question figure Which of the following statements is TRUE about how this Random Forest model will behave?
  1. With bootstrap=True, every tree sees the entire dataset, but the samples are shuffled randomly for each tree.
  2. 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. Setting max_features=5 means only 5 trees out of 200 will use feature subsets, while the rest use all features.
  4. Each tree will consider only 5 randomly chosen features when looking for the best split at every node.
Q44SA2 marks
What will be the output of the following code ? (Round to two decimals) question figure
Q45MCQ1 mark
If pval = 0.03 for the following code, which of the option is correct at the 5% level? question figure
  1. Series is non-stationary.
  2. Series is stationary.
  3. The series has trend.
  4. The series is noise.
Q46MCQ2 marks
You are given the following four implementations of cosine similarity in NumPy. Which function correctly computes cosine similarity?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q47MSQ1 markselect all that apply
Which of the following can be used to evaluate the outputs of the K-Means algorithm?
  1. Negative Mean Absolute Error
  2. Silhoutte Score
  3. F1 Score
  4. R2 Score
  5. Inertia
Q48MSQ2 marksselect all that apply
Select the correctly matched pairs of sklearn functions with the use of fit, fit_transform and transform.
  1. Learning the weights of logistic regression model on training data - fit_transform
  2. Creating a decision tree on the training data - fit
  3. fitting MinMaxScaler on test data - fit_transform
  4. fitting MinMaxScaler on train data - fit_transform
Q49SA1 mark
What is the output of the following code? question figure
Q50MCQ1 mark
Following is the code to tune the degree parameter of a polynomial regression model. question figure What should the blank space contain?
  1. "degree"
  2. "PolynomialFeatures_degree"
  3. "sgd__degree"
  4. "poly__degree"
Q51MSQ1 markselect all that apply
Which of the following is a hyper parameter?
  1. intercept_ in LinearRegression
  2. degree in PolynomialFeatures
  3. n_neighbors in Ridge
  4. min_samples_split in DecisionTreeClassifier
Q52MCQ1 mark
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. question figure
  2. question figure
  3. question figure
  4. question figure
Q53SA2 marks
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: question figure What is the value of ? Enter your answer rounded to three decimal places
Q54MCQ2 marks
Which of the following is required for user-based collaborative filtering?
  1. User–item interaction matrix
  2. Item content features
  3. User features (e.g. age, gender etc.)
  4. Image embeddings
Q55SA2 marks
Compute cosine similarity for the two items which have feature vectors as given below(rounded to 2 decimals).
Q56SA2 marks
Consider the following code snippet: question figure If the shape of X is , what will be the number of features in X_transformed?
Q57MCQ2 marks
Given the following code using BaggingClassifier with KNeighborsClassifier as the base estimator: question figure Which of the following statements is correct?
  1. Above code uses bootstrapping to generate samples for each base classifier.
  2. model will be tested on out of the bags samples.
  3. Due to weights="distance", each base KNN classifier will treat all neighbors equally in terms of voting power.
  4. The ensemble will consist of 3 base KNN classifiers.
  5. None of these
Q58MSQ2 marksselect all that apply
Which of the following algorithms may get impacted by feature scaling?
  1. LinearRegression
  2. DecisionTree
  3. SVM
  4. NaiveBayes
Q59MCQ2 marks
Given below a y_train list which consists of coffee order's preference by the customers in a cafe. question figure 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 ? question figure
  1. [[1 0 1 0],[1 0 0 1],[0 1 0 1],[0 1 1 0]]
  2. [[0 0],[1 0],[0 1],[1 1],[1 0],[0 0],[0 0],[0 0]]
  3. [[1 0 1 0 0 1 0 0],[1 0 0 1 1 0 0 0]]
  4. [[1 0][1 0],[1 0] [0 1],[0 1] [0 1],[0 1][1 0]]
Q60MCQ2 marks
What could be the output for below code question figure
  1. ['document' 'first' 'is' 'second' 'the' 'this']
  2. {'this': 5, 'is': 2, 'the': 4, 'first': 1, 'document': 0, 'second': 3}
  3. [5, 2, 4, 1, 0, 3]
  4. question figure

Answer key

  1. Q1 (MCQ, 2 marks): B
  2. Q2 (MCQ, 2 marks): B
  3. Q3 (MCQ, 1 marks): C
  4. Q4 (MCQ, 2 marks): B
  5. Q5 (MCQ, 2 marks): C
  6. Q6 (SA, 2 marks): 0
  7. Q7 (SA, 1 marks): 0.72 to 0.78
  8. Q8 (MSQ, 2 marks): D
  9. Q9 (SA, 2 marks): 3
  10. Q10 (MCQ, 1 marks): C
  11. Q11 (SA, 1 marks): 0.25 to 0.29
  12. Q12 (MCQ, 2 marks): B
  13. Q13 (MCQ, 1 marks): C
  14. Q14 (MCQ, 1 marks): B
  15. Q15 (SA, 2 marks): 7
  16. Q16 (SA, 2 marks): 0
  17. Q17 (MSQ, 2 marks): A, B
  18. Q18 (MCQ, 1 marks): A
  19. Q19 (MCQ, 2 marks): A
  20. Q20 (MCQ, 1 marks): C
  21. Q21 (SA, 2 marks): 140
  22. Q22 (MCQ, 1 marks): D
  23. Q23 (MCQ, 2 marks): B
  24. Q24 (MCQ, 2 marks): B
  25. Q25 (MCQ, 1 marks): C
  26. Q26 (SA, 2 marks): 5
  27. Q27 (MSQ, 2 marks): B, C, D
  28. Q28 (MSQ, 2 marks): A, D
  29. Q29 (MCQ, 2 marks): B
  30. Q30 (MCQ, 2 marks): B
  31. Q31 (MCQ, 1 marks): C
  32. Q32 (MCQ, 1 marks): B
  33. Q33 (MSQ, 1 marks): A, C, E
  34. Q34 (MCQ, 1 marks): C
  35. Q35 (SA, 2 marks): 0.73 to 0.77
  36. Q36 (SA, 2 marks): 6
  37. Q37 (MCQ, 2 marks): C
  38. Q38 (SA, 2 marks): 0
  39. Q39 (MSQ, 2 marks): A, D
  40. Q40 (SA, 2 marks): 80.00
  41. Q41 (MCQ, 2 marks): D
  42. Q42 (MCQ, 2 marks): B
  43. Q43 (MCQ, 2 marks): D
  44. Q44 (SA, 2 marks): 0.5
  45. Q45 (MCQ, 1 marks): B
  46. Q46 (MCQ, 2 marks): C
  47. Q47 (MSQ, 1 marks): B, E
  48. Q48 (MSQ, 2 marks): B, D
  49. Q49 (SA, 1 marks): 4
  50. Q50 (MCQ, 1 marks): D
  51. Q51 (MSQ, 1 marks): B, D
  52. Q52 (MCQ, 1 marks): B
  53. Q53 (SA, 2 marks): 0.230 to 0.240
  54. Q54 (MCQ, 2 marks): A
  55. Q55 (SA, 2 marks): 0.61 to 0.65
  56. Q56 (SA, 2 marks): 36
  57. Q57 (MCQ, 2 marks): E
  58. Q58 (MSQ, 2 marks): A, C
  59. Q59 (MCQ, 2 marks): A
  60. Q60 (MCQ, 2 marks): B