ML Study Hub

Home / Past papers / MLP End Term / this paper

IIT M FOUNDATION FN EXAM FDF1 24 Dec 2023 - 24 Dec 2023

MLP End Term38 questions100 marks22 MCQ · 11 MSQ · 5 SAFoundation / forenoon
Elapsed 00:00
Q1MCQ2 marks
Consider the following Python code using Pandas: question figure Consider the following Python code using Pandas: What does the groupby operation in the code achieve?
  1. It calculates the total price for each category.
  2. It calculates the average price for each category.
  3. It groups the data by the ’Category’ column.
  4. It filters out rows where the ’Price’ column is zero.
Q2MCQ2 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q3MCQ2 marks
Which of the following metrics indicate higher their value, better the regression model’s performance?
  1. RMSE
  2. R2
  3. Mean absolute error
  4. Mean squared error
Q4MCQ2 marks
Which of the following variations of gradient descent can be implemented with SGDClassifier?
  1. stochastic gradient descent
  2. mini gradient descent
  3. full batch gradient descent
  4. None of these
Q5MCQ2 marks
Consider the Ridge regression model in scikit-learn, represented by the Ridge class. Which of the following statements about Ridge regression is correct?
  1. Ridge regression is designed to handle class imbalance of the dataset.
  2. The regularization term in Ridge regression is added to the sum of absoluteresiduals.
  3. Increasing the value of the regularization parameter (alpha) in Ridgeregression makes the model less sensitive to high-magnitude coefficients.
  4. Ridge regression is equivalent to Lasso regression when the regularizationparameter (alpha) is set to zero.
Q6MCQ2 marks
Which of the following method is used to estimate the probabilities in SGD-Classifier with suitable loss?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q7MCQ2 marks
question figure
  1. Faster to compute the list of neighbors on scaled data.
  2. k-nearest neighbors is based on computing some distances. Features need tobe normalized to contribute approximately equally to the distance computation.
  3. Scaling the data has a negligible effect on k-nearest neighbor’s performance,but it enhances the interpretability of the model.
  4. This is irrelevant. One could use k-nearest neighbors without normalizing thedataset and get a very similar cross-validation score.
Q8MCQ2 marks
When using CountVectorizer in scikit-learn, what does the max_features parameter control?
  1. The maximum number of documents considered during vectorization.
  2. The maximum number of features (words) to be extracted based on termfrequency.
  3. The maximum number of randomly selected features (words).
  4. The maximum number of characters allowed in each document.
Q9MCQ2 marks
Which of these may NOT help in handling overfitting in decision trees?
  1. Increasing the value of min_samples_split
  2. Increasing the value of the pruning parameter
  3. Increasing the value of min_samples_leaf
  4. Increasing the depth of the tree
Q10MCQ2 marks
Which of the following is/are Clustering Method.
  1. Connectivity-based Clustering
  2. Centroids-based Clustering
  3. Density-based Clustering
  4. All of them
Q11MCQ2 marks
You’re working with a large image and want to group similarly coloured segments in the image together. No other information is provided with the image. Which of the following techniques will you use to accomplish the task?
  1. Supervised learning
  2. Unsupervised learning
  3. Reinforcement learning
  4. None of these
Q12MCQ2 marks
question figure
  1. logistic
  2. relu
  3. identity
  4. tanh
Q13MCQ3 marks
question figure
  1. [5, 5, 3.75]
  2. [5, 5, 3]
  3. [4, 4, 3]
  4. [4, 4, 3.75]
Q14MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q15MCQ3 marks
Which of the following code snippets represent correct methods to obtain cross validated performance measure using LeaveOneOut?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
  5. question figure
Q16MCQ3 marks
question figure
  1. (71)
  2. (71, 1)
  3. (10)
  4. (10, 2)
Q17MCQ3 marks
You’re building an ‘MLPClassifier‘ for a dataset with a large number of features. The goal is to predict whether a patient is going to have parkinson disease in next 12 months. You’re trying to decide the appropriate number of neurons in the hidden layers of the neural network. Which statement about adjusting the hidden_layer_sizes parameter is correct?
  1. Increasing the number of neurons in hidden layers will always lead to bettermodel performance.
  2. Decreasing the number of neurons in hidden layers reduces the model’scapacity to capture complex patterns.
  3. The number of neurons in hidden layers does not significantly affect themodel’s performance.
  4. Finding the optimal number of neurons is a trial-and-error process and mayrequire experimentation.
Q18MCQ3 marks
Which of the following code snippet can correctly plot the elbow graph for feature matrix X (k value is taken from 1 to 10)?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
  5. question figure
Q19MCQ3 marks
question figure
  1. Increasing the model’s complexity to fit the training data more closely.
  2. Adding a stronger regularization term to the loss function, discouragingcomplex models.
  3. Making the model more capable to learn more complex behaviour.
  4. Adjusting the learning rate to control convergence speed.
Q20MCQ4 marks
question figure
  1. Output score is likely to increase.
  2. Output score is likely to decrease.
  3. Output score may increase or decrease.
  4. Output score will remain the same.
Q21MCQ4 marks
question figure
  1. 0
  2. 1
  3. 2
  4. 3
Q22MCQ4 marks
question figure
  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 neighborsequally in terms of voting power.
  4. The ensemble will consist of 3 base KNN classifiers.
  5. None of these
Q23MSQ2 marksselect all that apply
Consider a dataset representing various attributes of red wine, loaded into a Pandas DataFrame named data using the following code: question figure Consider a dataset representing various attributes of red wine, loaded into a Pandas DataFrame named data using the following code: Suppose we are interested in extracting the value of the chlorides attribute for the third sample in the dataset (2nd by index). Which of the following expressions correctly achieves this? chlorides is at the 4th index of columns.
  1. data.chlorides[2]
  2. data[’chlorides’][2]
  3. data[2][4]
  4. data.iloc[2, 4]
Q24MSQ2 marksselect all that apply
question figure
  1. It applies lasso penalty.
  2. The training may terminate after 499 iterations or lesser
  3. the classifier represents a perceptron model
  4. The classifier’s model parameters will initialized with parameters learnt fromprevious call to fit() function, if the same object is trained/fitted multiple times on new data.
Q25MSQ2 marksselect all that apply
Which of the following observations warrant use of SGD model?
  1. The data set size is 1000 GB.
  2. The model has to be trained in non-iterative manner.
  3. The model must be a decision tree.
  4. The model must be a logistic regressor.
  5. None of these
Q26MSQ2 marksselect all that apply
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q27MSQ2 marksselect all that apply
question figure
  1. ‘poly’,
  2. ‘lasso’
  3. ‘rbf’,
  4. ‘scale’
Q28MSQ3 marksselect all that apply
question figure
  1. malic_acid
  2. magnesium
  3. flavanoids
  4. proanthocyanins
  5. color_intensity
  6. proline
Q29MSQ3 marksselect all that apply
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q30MSQ3 marksselect all that apply
question figure
  1. [47, 31, 18, 95, 77]
  2. [47, 31, 18 ]
  3. [31, 41, 18, 95, 85, 77]
  4. [31, 41, 85, 31]
  5. [18, 95, 85, 77]
  6. [47, 31, 18, 85]
  7. None of these
Q31MSQ3 marksselect all that apply
When using a Support Vector Classifier (SVC) in scikit-learn with different values of the regularization parameter (C), how does the complexity of the decision boundary change? Select all correct statements:
  1. Smaller values of C result in a more complex decision boundary.
  2. Larger values of C result in a more complex decision boundary.
  3. The decision boundary becomes simpler with increasing values of C.
  4. Very large values of C may lead to overfitting.
Q32MSQ4 marksselect all that apply
question figure
  1. Number of samples at node N = 10. If it is split, it will result in 2 nodes in theleft child and 8 nodes in the right child.
  2. Number of samples at node N = 6. If it is split, it will result in 3 nodes in the leftchild and 3 nodes in the right child.
  3. Number of samples at node N = 12. If it is split, it will result in 5 nodes in theleft child and 7 nodes in the right child.
  4. Number of samples at node N = 4. If it is split, it will result in 3 nodes in the leftchild and 1 node in the right child.
Q33SA3 marks
question figure
Q34SA3 marks
question figure
Q35SA2 marks
question figure
Q36SA4 marks
question figure
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q37SA3 marks
How many Accidents per 1000 Driver happens for Age 25 and driving blue car ?
Q38MSQ2 marksselect all that apply
To improve the given model which of the following preprocessing step you suggest?
  1. StandardScaler()
  2. OrdinalEncoder()
  3. MinMaxScaler()
  4. LabelEncoder()

Answer key

  1. Q1 (MCQ, 2 marks): B
  2. Q2 (MCQ, 2 marks): D
  3. Q3 (MCQ, 2 marks): B
  4. Q4 (MCQ, 2 marks): A
  5. Q5 (MCQ, 2 marks): C
  6. Q6 (MCQ, 2 marks): A
  7. Q7 (MCQ, 2 marks): B
  8. Q8 (MCQ, 2 marks): B
  9. Q9 (MCQ, 2 marks): D
  10. Q10 (MCQ, 2 marks): D
  11. Q11 (MCQ, 2 marks): B
  12. Q12 (MCQ, 2 marks): C
  13. Q13 (MCQ, 3 marks): B
  14. Q14 (MCQ, 3 marks): B
  15. Q15 (MCQ, 3 marks): A
  16. Q16 (MCQ, 3 marks): C
  17. Q17 (MCQ, 3 marks): D
  18. Q18 (MCQ, 3 marks): C
  19. Q19 (MCQ, 3 marks): C
  20. Q20 (MCQ, 4 marks): A
  21. Q21 (MCQ, 4 marks): B
  22. Q22 (MCQ, 4 marks): E
  23. Q23 (MSQ, 2 marks): A, B, D
  24. Q24 (MSQ, 2 marks): B, D
  25. Q25 (MSQ, 2 marks): A, D
  26. Q26 (MSQ, 2 marks): A, C
  27. Q27 (MSQ, 2 marks): A, C
  28. Q28 (MSQ, 3 marks): C, E, F
  29. Q29 (MSQ, 3 marks): A, C, D
  30. Q30 (MSQ, 3 marks): A, B, C, D
  31. Q31 (MSQ, 3 marks): B, D
  32. Q32 (MSQ, 4 marks): A, D
  33. Q33 (SA, 3 marks): 0.6
  34. Q34 (SA, 3 marks): 1
  35. Q35 (SA, 2 marks): 2
  36. Q36 (SA, 4 marks): 500
  37. Q37 (SA, 3 marks): 73 to 75
  38. Q38 (MSQ, 2 marks): A, C

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Here’s a structured summary of core topics, concepts, principles, and equations essential for the Diploma Level: Machine Learning Practice (Computer-Based Exam). The summary is organized by domains (e.g., Data Preprocessing, Supervised Learning, Unsupervised Learning, Model Evaluation, etc.), followed by key equations (where applicable) and Mermaid knowledge graphs to visualize relationships.


1. Core Topics & Concepts

A. Data Preprocessing

Key Concepts:

  1. Handling Missing Data

    • SimpleImputer (mean/median/mode imputation).
    • Equation for mean imputation:
Imputed value=1n∑i=1nxi(for column j)\text{Imputed value} = \frac{1}{n} \sum_{i=1}^n x_i \quad \text{(for column } j\text{)}
  1. Feature Scaling

    • StandardScaler: Standardizes features to have mean=0 and variance=1.
z=x−μσz = \frac{x - \mu}{\sigma}
xscaled=x−min⁡(X)max⁡(X)−min⁡(X)x_{\text{scaled}} = \frac{x - \min(X)}{\max(X) - \min(X)}
  1. Categorical Encoding

    • One-Hot Encoding: Converts categorical variables into binary columns.

      • Example: Car_color → Black, Blue, Red (binary columns).
    • Ordinal Encoding: Assigns integers to categories (use if ordinal relationship exists).
    • Label Encoding: Assigns integers to categories (not recommended for nominal data).
  1. Feature Selection

    • SelectKBest: Selects top-k features based on statistical tests (e.g., chi-squared, ANOVA).
    • Example: SelectKBest(chi2, k=3) selects the 3 best features based on chi-squared scores.

B. Supervised Learning

Key Concepts:

  1. Linear Models

    • Logistic Regression:

      • Outputs probabilities via sigmoid function:
P(y=1)=11+e−(β0+β1x1+⋯+βnxn)P(y=1) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \dots + \beta_n x_n)}}
MSE+α∑i=1nβi2\text{MSE} + \alpha \sum_{i=1}^n \beta_i^2
MSE+α∑i=1n∣βi∣\text{MSE} + \alpha \sum_{i=1}^n |\beta_i|
  1. Support Vector Machines (SVM)

    • Linear SVM:

      • Decision function: f(x)=sign(wTx+b)f(x) = \text{sign}(w^T x + b).
      • Regularization (C): Smaller C → wider margin (simpler model).
    • Kernel Trick:

      • Transforms data into higher dimensions for non-linear separation.
      • Common kernels: linear, poly, rbf, sigmoid.
  1. Decision Trees

    • Splitting Criteria:

      • Gini impurity (for classification):
G=1−∑i=1cpi2G = 1 - \sum_{i=1}^c p_i^2
H=−∑i=1cpilog⁡(pi)H = -\sum_{i=1}^c p_i \log(p_i)
  1. Neural Networks (MLP)

    • Architecture:

      • Input layer → Hidden layer(s) → Output layer.
      • Number of parameters for 1 hidden layer:
(ninput×nhidden)+nhidden+(nhidden×noutput)+noutput(n_{\text{input}} \times n_{\text{hidden}}) + n_{\text{hidden}} + (n_{\text{hidden}} \times n_{\text{output}}) + n_{\text{output}}
  1. Stochastic Gradient Descent (SGD)

    • Loss Functions:

      • hinge: SVM.
      • log_loss: Logistic regression.
      • squared_error: Linear regression.
    • Penalties:

      • l1 (Lasso), l2 (Ridge), elasticnet.
    • Key Parameters:

      • learning_rate: Step size for updates.
      • max_iter: Maximum epochs.
      • warm_start: Reuse previous solution for incremental learning.

C. Unsupervised Learning

Key Concepts:

  1. Clustering

    • K-Means:

      • Objective: Minimize inertia (within-cluster sum of squares):
Inertia=∑i=1nmin⁡μj∈C∣∣xi−μj∣∣2\text{Inertia} = \sum_{i=1}^n \min_{\mu_j \in C} ||x_i - \mu_j||^2
  1. Dimensionality Reduction

    • PCA (Principal Component Analysis):

      • Transforms data to orthogonal components (ordered by variance).
      • First PC: Direction of maximum variance.

D. Model Evaluation & Hyperparameter Tuning

Key Concepts:

  1. Evaluation Metrics

    • Classification:

      • Accuracy, Precision, Recall, F1-score, ROC-AUC.
    • Regression:

      • R² (R-squared): Higher is better (1 = perfect fit).
R2=1−SSresSStotR^2 = 1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}}
RMSE=1n∑i=1n(yi−y^i)2\text{RMSE} = \sqrt{\frac{1}{n} \sum_{i=1}^n (y_i - \hat{y}_i)^2}
  1. Cross-Validation

    • K-Fold CV: Splits data into k folds; trains on k-1 folds, tests on 1.
    • Leave-One-Out (LOO): Extreme case of K-Fold where k = n (computationally expensive).
    • Stratified K-Fold: Preserves class distribution in each fold.
  1. Hyperparameter Tuning

    • GridSearchCV: Exhaustive search over specified parameter values.
    • RandomizedSearchCV: Randomly samples parameter combinations (faster for large spaces).
    • Example:

      param_grid = {'C': [0.1, 1, 10], 'kernel': ['linear', 'rbf']}
      grid_search = GridSearchCV(SVC(), param_grid, cv=5)
  1. Bias-Variance Tradeoff

    • Underfitting (High Bias): Model is too simple (increase complexity).
    • Overfitting (High Variance): Model memorizes noise (regularize, prune, or get more data).

E. Ensemble Methods

Key Concepts:

  1. Bagging (Bootstrap Aggregating)

    • Random Forest: Ensemble of decision trees trained on bootstrapped samples.
    • Reduces variance by averaging predictions.
  1. Boosting

    • Gradient Boosting: Sequentially corrects errors of previous models.
    • AdaBoost: Weights misclassified samples higher in subsequent iterations.
  1. Voting Classifier

    • Hard Voting: Majority class from multiple models.
    • Soft Voting: Average probabilities from multiple models.

F. Practical Scenarios

ScenarioRecommended Approach
Large dataset (1000+ GB)SGDClassifier (incremental learning)
Non-linear decision boundaryKernel SVM or Neural Networks
High-dimensional dataRidge Regression or PCA + Linear Model
Imbalanced classesAdjust class weights or use SMOTE
Feature importance neededRandom Forest or Lasso Regression
Clustering similar itemsK-Means (if spherical clusters) or DBSCAN

2. Key Equations Summary

ConceptEquation
Standard Scalingz=x−μσz = \frac{x - \mu}{\sigma}
MinMax Scalingxscaled=x−min⁡(X)max⁡(X)−min⁡(X)x_{\text{scaled}} = \frac{x - \min(X)}{\max(X) - \min(X)}
Logistic RegressionP(y=1)=11+e−(β0+β1x1+⋯+βnxn)P(y=1) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \dots + \beta_n x_n)}}
Ridge RegressionMSE+α∑i=1nβi2\text{MSE} + \alpha \sum_{i=1}^n \beta_i^2
Lasso RegressionMSE+α∑i=1n∣βi∣\text{MSE} + \alpha \sum_{i=1}^n |\beta_i|
K-Means Inertia∑i=1nmin⁡μj∈C∣∣xi−μj∣∣2\sum_{i=1}^n \min_{\mu_j \in C} ||x_i - \mu_j||^2
R² ScoreR2=1−SSresSStotR^2 = 1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}}
RMSE1n∑i=1n(yi−y^i)2\sqrt{\frac{1}{n} \sum_{i=1}^n (y_i - \hat{y}_i)^2}
Gini ImpurityG=1−∑i=1cpi2G = 1 - \sum_{i=1}^c p_i^2
EntropyH=−∑i=1cpilog⁡(pi)H = -\sum_{i=1}^c p_i \log(p_i)
MLP Parameters (1 hidden)(ninput×nhidden)+nhidden+(nhidden×noutput)+noutput(n_{\text{input}} \times n_{\text{hidden}}) + n_{\text{hidden}} + (n_{\text{hidden}} \times n_{\text{output}}) + n_{\text{output}}

Graph 2: Supervised Learning Algorithms

Graph 3: Unsupervised Learning

Graph 4: Model Evaluation Metrics

Graph 5: Hyperparameter Tuning


4. Exam Tips

  1. Pandas Operations:

    • groupby().mean() → Calculates average per group.
    • df.iloc[row, col] → Access by integer position.
    • df['column'][index] → Access column by name and row by index.
  1. Scikit-Learn Syntax:

    • fit() → Train the model.
    • predict() → Generate predictions.
    • predict_proba() → Class probabilities (for classifiers).
    • score() → Returns accuracy (for classifiers) or R² (for regressors).
  1. Common Pitfalls:

    • Forgetting to scale data for distance-based models (KNN, SVM, Neural Networks).
    • Misinterpreting alpha in Ridge/Lasso (higher α = stronger regularization).
    • Confusing min_samples_split and min_samples_leaf in decision trees.
  1. Key Takeaways:

    • Overfitting: Mitigate with regularization, pruning, or cross-validation.
    • Underfitting: Increase model complexity or add features.
    • Feature Importance: Use coef_ (linear models) or feature_importances_ (tree-based models).

5. Quick Reference Table

TopicKey Points
StandardScalerMean=0, Std=1; use for distance-based models.
Ridge vs. LassoRidge: L2 (shrinks coefficients); Lasso: L1 (can zero coefficients).
SGDClassifierUse loss='hinge' for SVM, loss='log_loss' for logistic regression.
K-MeansElbow method to choose k; inertia = within-cluster sum of squares.
Decision Treesmax_depth controls complexity; deeper trees risk overfitting.
Neural Networkshidden_layer_sizes=(10,) for 1 hidden layer with 10 neurons.
Cross-Validationcv=5 in GridSearchCV → 5-fold cross-validation.
Voting Classifiervoting='soft' for probability averaging; 'hard' for majority class.
Imbalanced DataUse class_weight='balanced' or SMOTE.
PCAReduces dimensions; first component = max variance direction.