ML Study Hub

Home / Past papers / MLP End Term / this paper

IIT M IMPROVEMENT FN EXAM QDD1 01 Sep - 01 Sep 2024

MLP End Term37 questions100 marks20 MCQ · 11 SA · 6 MSQImprovement / forenoon / QDD1
Elapsed 00:00
Comprehension passage - the questions below it refer to this
Consider following common data and answer the subquestions: question figure Consider following common data and answer the subquestions:
Q1SA2 marks
What will be the output of the following code snippet? question figure What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
Q2SA2 marks
What will be the output of the following code snippet? question figure What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
Q3SA2 marks
What will be the output of the following code snippet? question figure What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
Q4SA2 marks
How many columns have datatype as ”float64”?
Q5SA2 marks
What will be the output of the following code snippet? question figure What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
Q6SA2 marks
Consider following parameter grid for regression with RandomForest: question figure Consider following parameter grid for regression with RandomForest: How many unique combinations of hyperparameters are there in the above parameter grid?
Q7MCQ1 mark
How to make SGDRegressor stop after 1000 epochs?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q8MCQ2 marks
question figure
  1. DictVectorizer
  2. HashingVectorizer
  3. FeatureHasher
Q9MCQ2 marks
Which of the following is an example of an ordinal variable?
  1. Blood type (A, B, AB, O)
  2. Satisfaction rating (Very Unsatisfied, Unsatisfied, Neutral, Satisfied, VerySatisfied)
  3. Height of individuals
  4. Gender
Q10MCQ2 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q11MCQ2 marks
question figure
  1. cv
  2. reg_rate
  3. alpha
  4. tol
Q12MCQ3 marks
question figure
  1. 1000
  2. 100
  3. 99
  4. 999
Q13MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q14MCQ3 marks
question figure
  1. It determines whether to include a bias term in the model.
  2. It sets the degree of the polynomial features.
  3. It controls the regularization strength.
  4. It specifies the number of features to consider when fitting the model.
Q15MCQ3 marks
question figure
  1. To specify the maximum number of samples per leaf.
  2. To limit the depth of the tree.
  3. To set the minimum number of samples required to split an internal node.
  4. To control the minimum impurity decrease required for a split.
Q16MCQ3 marks
question figure
  1. It determines the function to measure the quality of a split.
  2. It specifies the number of features to consider when looking for the best split.
  3. It sets the strategy used to choose the split at each node.
  4. It controls whether to use the Gini impurity or entropy.
Q17MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q18MCQ3 marks
Consider below statements and choose the correct option: Statement1:The bagging technique combines multiple models trained on different subsets of data Statement2:The Boosting technique trains the model Parallelly, focusing on the error made by the other model.
  1. Statement1 is True, Statement2 is True
  2. Statement1 is True, Statement2 is False
  3. Statement1 is False, Statement2 is True
  4. Statement1 is False, Statement2 is False
Q19MCQ3 marks
How does agglomerative clustering handle outliers?
  1. It ignores outliers during the clustering process.
  2. It assigns outliers to the nearest cluster.
  3. It creates separate clusters for outliers.
  4. It removes outliers from the dataset before clustering.
Q20MCQ3 marks
What is agglomerative clustering?
  1. A hierarchical clustering technique that starts with each data point as itscluster and merges the closest clusters iteratively.
  2. A method for partitioning data into a predefined number of clusters.
  3. A clustering algorithm that uses centroids to iteratively assign data points toclusters.
  4. A dimensionality reduction technique that projects data onto a lower-dimensional space.
Q21MCQ3 marks
question figure
  1. The distance between cluster centroids
  2. The number of clusters formed
  3. The within-cluster sum of squared distances
  4. The silhouette coefficient
Q22MCQ4 marks
Consider the following ML task/steps for a regression dataset: 1. Read the data from a file (named ‘dataset.csv’). It has 7 columns. The last column is the target variable, all 6 features numerical. 2. Remove rows which has target values missing. 3. Split the data into training and test sets. Take randomly the 70% of rows in the training set and the rest of them into the test set. 4. Fill the missing values in the features by KNNImputer using 3 nearest neighbours. 5. Train a LinearRegression model on the training set. 6. Report R2 score on the test set. Which of the following code snippets correctly accomplishes the above task? Assume necessary imports.
  1. question figure
  2. question figure
  3. question figure
  4. question figure
  5. question figure
  6. question figure
Q23MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q24MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
  5. question figure
Q25MCQ4 marks
question figure
  1. The predictions are based on the majority vote.
  2. The predictions are based on the average of probabilities predicted by eachclassifier.
  3. The predictions are based on the weighted sum of the predictions.
  4. The predictions are based on the classifier with the highest accuracy
Q26MCQ4 marks
question figure
  1. 5 centroids are randomly initialized 10 times
  2. 10 centroids are randomly initialized 5 times
  3. 5 samples in the dataset are selected as initialization point such that they areat least 10 units away from each other
  4. 10 samples in the dataset are selected as initialization point such that they areat least 5 units away from each other
Q27MSQ2 marksselect all that apply
Data snooping:
  1. Leads to biased estimation on test sets
  2. Increases the risk of false positives
  3. Leads to better estimation on training sets
  4. Reduces the risk of false positives
Q28MSQ2 marksselect all that apply
Which of the following algorithms may get impacted by feature scaling?
  1. LinearRegression
  2. DecisionTree
  3. SVM
  4. NaiveBayes
Q29MSQ3 marksselect all that apply
question figure
  1. The logistic regression model will use equal weights for both the classes in animbalanced dataset.
  2. The model does not use any regularization because the parameter C is set.
  3. The “balanced” mode uses the values of y to automatically adjust weightsinversely proportional to class frequencies in the input data.
  4. The value of C indicates that the model will apply a regularization.
Q30MSQ3 marksselect all that apply
Which of the following statements are true?
  1. KNeighborsClassifier with high values of n_neighbors produces complexdecision boundaries.
  2. KNeighborsClassifier with high values of n_neighbors produces smoothdecision boundaries.
  3. In KNeighborsClassifier the scale of the features(columns) can impact thedecision boundaries.
  4. None of these
Q31MSQ3 marksselect all that apply
Which options are correct for Support Vectors in SVM ?
  1. Support vectors are the data points nearest to the hyperplane
  2. Using these support vectors, we maximize the margin of the classifier.
  3. Using these support vectors, we minimize the margin of the classifier.
  4. None of these
Q32MSQ3 marksselect all that apply
Which of the following are correct for Kmeans clustering algorithm?
  1. It only finds spherical clusters.
  2. The output of the algorithms depends upon initial cluster centroids.
  3. It can automatically detect most appropriate value of k.
  4. None of these.
Q33SA3 marks
question figure
Q34SA3 marks
question figure
Q35SA3 marks
question figure
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q36SA2 marks
What will be the output of the following code? question figure What will be the output of the following code?
Q37SA2 marks
What will be the output of the following code? question figure What will be the output of the following code?

Answer key

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

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 exam covers Pandas, Scikit-Learn, ML algorithms, hyperparameter tuning, evaluation metrics, and clustering. Key areas are data preprocessing, model training, evaluation, and interpretation of results.


1. Core Topics & Concepts

A. Data Handling with Pandas

Key Operations:

  1. DataFrame Basics:

    • pd.DataFrame(data, columns)
    • df.shape → (rows, columns)
    • df.isna().sum().sum() → Total missing values.
    • df.value_counts() → Frequency of unique values in a column.
    • df.iloc[:, n] → Select column by index.
    • df.query("condition") → Filter rows based on a condition.
  1. Handling Missing Data:

    • df.dropna() → Remove rows/columns with missing values.
    • Imputation (e.g., KNNImputer).
  1. Descriptive Statistics:

    • df.mean() → Column-wise mean (ignores NaN by default).

Equations (if applicable):

Mean=∑i=1nxin−count of NaN\text{Mean} = \frac{\sum_{i=1}^{n} x_i}{n - \text{count of NaN}}

B. Machine Learning Algorithms

1. Linear Models

y=β0+β1x1+β2x2+⋯+βnxn+ϵy = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_n x_n + \epsilon
Loss=MSE+α∑i=1nβi2\text{Loss} = \text{MSE} + \alpha \sum_{i=1}^{n} \beta_i^2
Loss=MSE+α∑i=1n∣βi∣\text{Loss} = \text{MSE} + \alpha \sum_{i=1}^{n} |\beta_i|
σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}
wi←wi+η(y−y^)xiw_i \leftarrow w_i + \eta (y - \hat{y}) x_i

2. Tree-Based Models

3. Support Vector Machines (SVM)

Maximize 2∥w∥\text{Maximize } \frac{2}{\|w\|}

4. Nearest Neighbors (KNN)

5. Clustering

Inertia=∑i=1nmin⁡μj∈C∥xi−μj∥2\text{Inertia} = \sum_{i=1}^{n} \min_{\mu_j \in C} \|x_i - \mu_j\|^2

6. Dummy Classifier


C. Model Evaluation

1. Metrics

Accuracy=TP+TNTP+TN+FP+FN\text{Accuracy} = \frac{\text{TP} + \text{TN}}{\text{TP} + \text{TN} + \text{FP} + \text{FN}}
Precision=TPTP+FP\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}
Recall=TPTP+FN\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}
F1=2×Precision×RecallPrecision+Recall\text{F1} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
MSE=1n∑i=1n(yi−y^i)2\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2
R2=1−SSresSStotR^2 = 1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}}

where:

2. Cross-Validation


D. Feature Engineering

1. Polynomial Features

2. Feature Scaling

xscaled=x−μσx_{\text{scaled}} = \frac{x - \mu}{\sigma}
xscaled=x−min⁡(X)max⁡(X)−min⁡(X)x_{\text{scaled}} = \frac{x - \min(X)}{\max(X) - \min(X)}

3. Feature Selection


E. Hyperparameter Tuning


F. Ensemble Methods

1. Voting Classifier

2. Bagging vs. Boosting

BaggingBoosting
Trains models in parallel.Trains models sequentially.
Reduces variance (e.g., Random Forest).Reduces bias (e.g., AdaBoost, XGBoost).
Uses bootstrapped samples.Weights misclassified samples higher.

G. Data Leakage & Best Practices


H. Dimensionality Reduction

1. PCA (Principal Component Analysis)

Covariance Matrix=1nXTX\text{Covariance Matrix} = \frac{1}{n} X^T X

Eigenvectors of the covariance matrix = principal components.


2. Key Equations Summary

ConceptEquation
Linear Regressiony=β0+β1x1+⋯+βnxn+ϵy = \beta_0 + \beta_1 x_1 + \dots + \beta_n x_n + \epsilon
Ridge (L2) RegularizationLoss=MSE+α∑βi2\text{Loss} = \text{MSE} + \alpha \sum \beta_i^2
Lasso (L1) RegularizationLoss=MSE+α∑∣βi∣\text{Loss} = \text{MSE} + \alpha \sum |\beta_i|
Logistic Regressionσ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}
PrecisionTPTP+FP\frac{\text{TP}}{\text{TP} + \text{FP}}
RecallTPTP+FN\frac{\text{TP}}{\text{TP} + \text{FN}}
F1-Score2×Precision×RecallPrecision+Recall2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
R² Score1−SSresSStot1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}}
K-Means Inertia∑i=1nmin⁡μj∥xi−μj∥2\sum_{i=1}^{n} \min_{\mu_j} \|x_i - \mu_j\|^2
Standard Scalingxscaled=x−μσx_{\text{scaled}} = \frac{x - \mu}{\sigma}
Min-Max Scalingxscaled=x−min⁡(X)max⁡(X)−min⁡(X)x_{\text{scaled}} = \frac{x - \min(X)}{\max(X) - \min(X)}

Graph 2: Unsupervised Learning

Graph 3: Model Evaluation

Graph 4: Data Preprocessing

Graph 5: Hyperparameter Tuning

Graph 6: Ensemble Methods


4. Exam Tips

  1. Pandas:

    • Know how to count non-missing values (df.shape[0]*df.shape[1] - df.isna().sum().sum()).
    • Use value_counts() for frequency tables.
  1. Scikit-Learn:

    • Initialization: Check default parameters (e.g., SGDRegressor(max_iter=1000)).
    • Pipelines: Use make_pipeline for sequential preprocessing + modeling.
    • Evaluation: model.score(X, y) returns R2R^2 for regression and accuracy for classification.
  1. Algorithms:

    • Decision Trees: max_depth controls overfitting.
    • SVM: C controls regularization; higher C = less regularization.
    • KNN: n_neighbors affects bias-variance tradeoff (high n = smoother boundaries).
  1. Clustering:

    • K-Means: inertia_ = within-cluster sum of squares.
    • Agglomerative: Assigns outliers to the nearest cluster.
  1. Evaluation Metrics:

    • Precision/Recall Tradeoff: High precision = fewer FP; high recall = fewer FN.
    • Dummy Classifier: Baseline for comparison (e.g., strategy='most_frequent').
  1. Avoid Common Mistakes:

    • Data Leakage: Never fit scalers/imputers on the entire dataset before train-test split.
    • Parameter Names: alpha in Ridge/Lasso vs. C in LogisticRegression/SVM (they are inverses!).
    • Voting Classifier: voting='soft' requires estimators with predict_proba.