ML Study Hub

Home / Past papers / MLP End Term / this paper

Subject Name : 2023 Sep03: IIT M DIPLOMA ET1 EXAM - 03 Sep 2023

MLP End Term34 questions100 marks23 MCQ · 6 SA · 5 MSQDiploma
Elapsed 00:00
Q1SA2 marks
What will be the output of the following code: question figure What will be the output of the following code:
Q2SA2 marks
What will be the numerical value in the output array of the following code: question figure What will be the numerical value in the output array of the following code:
Q3MCQ2 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q4MCQ2 marks
question figure
  1. The predicted classes for the new data points.
  2. The decision boundary values for the classes.
  3. The posterior probabilities of the classes for the new data points.
  4. The likelihood estimates for the new data points.
Q5MCQ2 marks
question figure
  1. (15,2)
  2. (2,3)
  3. (2,15)
  4. (15,3)
Q6MCQ2 marks
You’re working on a dataset containing customer purchase data, and you want to segment the customers into distinct groups based on their purchasing behavior. Each data point represents a customer and includes features like ”Total Amount Spent” and ”Number of Items Purchased.” Which algorithm is suitable for this scenario?
  1. Linear Regression
  2. Decision Tree
  3. K-means Clustering
  4. Support Vector Machine
Q7MCQ2 marks
You’re working with a dataset of geographical locations and want to group similar locations together based on their distances. The dataset includes latitude and longitude coordinates for each location. Which linkage method would be most appropriate for this scenario?
  1. Complete Linkage
  2. Ward’s Linkage
  3. Single Linkage
  4. Average Linkage
Q8MCQ2 marks
You’re analyzing a dataset of customer transaction histories. Each transaction includes the purchase amount and timestamp. You want to identify groups of customers based on their spending behavior. Which clustering approach would be most appropriate for this scenario?
  1. Distribution-based Clustering
  2. Density-based Clustering
Q9MSQ3 marksselect all that apply
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q10MSQ3 marksselect all that apply
question figure
  1. MultinomialNB
  2. RandomForestRegressor
  3. LogisticRegressor
  4. SGDRegressor
Q11MSQ3 marksselect all that apply
Which of the following option(s) are correct regarding regularization?
  1. It is a technique used to minimize the adjusted loss function and avoidunderfitting.
  2. It helps in increasing the bias of the training model.
  3. It determines the rows to be selected as a training dataset.
  4. Elastic net regularization is a combination of L1 and L2 regularization both.
Q12MCQ3 marks
Given the following code snippet that preprocesses a dataset with both continuous and categorical features using sklearn.preprocessing tools, what will be the first row of the X transformed array after preprocessing? question figure Given the following code snippet that preprocesses a dataset with both continuous and categorical features using sklearn.preprocessing tools, what will be the first row of the X transformed array after preprocessing?
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q13MCQ3 marks
question figure
  1. (20640, 8)
  2. (20640, 5)
  3. (20640, 44)
  4. (20640, 49)
Q14MCQ3 marks
What is the main principle behind a dummy regressor’s prediction strategy?
  1. Predict the mean or median of the target variable for all instances.
  2. Fit a complex mathematical function to the data.
  3. Randomly shuffle the target variable values to make predictions.
  4. Predict the sum of the input features for each instance.
Q15MCQ3 marks
question figure
  1. It converts the numerical values in the data array to categorical labels.
  2. It standardizes the features in the data array to have zero mean and unitvariance.
  3. It applies a logarithmic transformation to the values in the data array.
  4. It removes the mean and scales the features in the data array to a specificrange.
Q16MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q17MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q18MCQ3 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q19MCQ3 marks
You’re working on a binary classification problem where the dataset is relatively small, and you suspect that a linear decision boundary will work well due to distinct class separation. Additionally, you want to perform logistic regression with L1 regularization for improved feature selection. Which solver is most appropriate for this scenario?
  1. Newton-CG
  2. SGD
  3. LBFGS
  4. Liblinear
Q20MCQ3 marks
question figure
  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.
Q21MCQ3 marks
You’re designing an ‘MLPClassifier’ for an image recognition task. The dataset consists of grayscale images of animals. You want to introduce non-linearity to the neural network’s architecture. Which element of the neural network architecture would you adjust to incorporate non-linearity in the model?
  1. Number of hidden layers
  2. Number of neurons in input layer
  3. Learning rate
  4. Activation function
Q22MCQ3 marks
You’re working on a binary classification task using the ‘MLPClassifier’ to predict whether a customer will make a purchase based on their browsing behavior.You’re concerned about overfitting due to the complexity of the model. You decide to increase the ‘alpha’ parameter to control overfitting. The following code snippet shows the application of ‘MLPClassifier’: question figure You’re working on a binary classification task using the ‘MLPClassifier’ to predict whether a customer will make a purchase based on their browsing behavior.You’re concerned about overfitting due to the complexity of the model. You decide to increase the ‘alpha’ parameter to control overfitting. The following code snippet shows the application of ‘MLPClassifier’:
  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 sensitive to outliers and noise in the data.
  4. Adjusting the learning rate to control convergence speed.
Q23SA3 marks
question figure
Q24SA3 marks
Using the confusion matrix given below. What is the precision score for the label (class) 1 ? question figure Using the confusion matrix given below. What is the precision score for the label (class) 1 ?
Q25SA3 marks
question figure
Q26SA3 marks
question figure
Q27MSQ4 marksselect all that apply
Which of the following statements are true?
  1. KNeighborsClassifier with low values of n_neighbors produces complexdecision boundaries.
  2. KNeighborsClassifier with low values of n_neighbors produces smoothdecision boundaries.
  3. In KNeighborsClassifier the scale of the features(columns) can impact thedecision boundaries.
  4. None of these
Q28MSQ2 marksselect all that apply
Fill in the missing parameter value in the following estimator that can be used to classify the data question figure Fill in the missing parameter value in the following estimator that can be used to classify the data
  1. ‘lasso’
  2. ‘linear’,
  3. ‘rbf’,
  4. ‘scale’
Q29MCQ4 marks
question figure
  1. question figure
  2. question figure
Q30MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q31MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q32MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q33MCQ4 marks
question figure
  1. question figure
  2. question figure
  3. question figure
  4. question figure
Q34MCQ4 marks
You’re working with a dataset of customer purchase behavior, including attributes “Total Amount Spent” and “Number of Items Purchased.” You decide to use K-means clustering to segment customers into groups based on these features. The following code snippet demonstrates the K-means clustering process: question figure You’re working with a dataset of customer purchase behavior, including attributes “Total Amount Spent” and “Number of Items Purchased.” You decide to use K-means clustering to segment customers into groups based on these features. The following code snippet demonstrates the K-means clustering process:
  1. The total amount spent by each customer.
  2. The cluster assignments indicating which group each customer belongs to.
  3. The number of items purchased by each customer.
  4. The centroid coordinates of the clusters formed.

Answer key

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

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 data preprocessing, supervised/unsupervised learning, model evaluation, and neural networks, with a focus on scikit-learn implementations.



1. Core Topics & Concepts

A. Data Preprocessing

Key Concepts:

  1. Scaling/Normalization

    • Standardization (StandardScaler): Transforms data to have mean = 0 and variance = 1.

      • Formula:
z=x−μσz = \frac{x - \mu}{\sigma}
xscaled=x∣Xmax∣x_{\text{scaled}} = \frac{x}{|X_{\text{max}}|}
xscaled=x−XminXmax−Xminx_{\text{scaled}} = \frac{x - X_{\text{min}}}{X_{\text{max}} - X_{\text{min}}}
  1. Handling Missing Data

    • SimpleImputer: Replaces missing values with mean, median, or mode.

      • Example: SimpleImputer(strategy='mean')
  1. Categorical Encoding

    • LabelEncoder: Converts categorical labels to numeric (0, 1, 2, ...).

      • Example: encoder.fit_transform(["cat", "dog", "fish"]) → [0, 1, 2]
    • MultiLabelBinarizer: Converts categorical labels to binary vectors.

      • Example:

        mlb = MultiLabelBinarizer(classes=['cold', 'hot', 'large', 'small'])
        mlb.fit_transform([['large', 'cold'], ['small', 'hot']])

        Output:

        [[1, 0, 1, 0], [0, 1, 0, 1]]
  1. Polynomial Features

    • PolynomialFeatures: Generates interaction terms and polynomial features.

      • Example: PolynomialFeatures(degree=2, interaction_only=True)
      • For input [a, b], output includes [a, b, a*b] (if interaction_only=True).
  1. Pipelines & Feature Unions

    • Pipeline: Chains multiple preprocessing steps.

      • Example:

        pipe = Pipeline([
            ('impute', SimpleImputer(strategy='mean')),
            ('scale', StandardScaler())
        ])
    • FeatureUnion: Combines multiple feature transformations.

      • Example:

        combined = FeatureUnion([
            ('poly', PolynomialFeatures(degree=2)),
            ('pca', PCA(n_components=2))
        ])

B. Supervised Learning

Key Algorithms & Concepts:

  1. Linear Models

    • Linear Regression:

      • Equation:
Y=W0X0+W1X1+⋯+WnXn+ϵY = W_0 X_0 + W_1 X_1 + \dots + W_n X_n + \epsilon
  1. Naive Bayes

    • GaussianNB: Assumes features follow a normal distribution.

      • predict_proba() → Returns posterior probabilities.
  1. k-Nearest Neighbors (KNN)

    • Hyperparameters:

      • n_neighbors: Low value → complex boundaries (prone to overfitting).
      • weights='uniform' (all neighbors equal) or 'distance' (weight by inverse distance).
      • metric='euclidean' (default) or 'manhattan'.
    • Scaling matters: Features should be scaled (e.g., StandardScaler).
  1. Support Vector Machines (SVM)

    • Kernel Trick: Transforms data into higher dimensions.

      • kernel='linear', 'rbf', 'poly'.
    • Regularization: C controls margin strictness.
  1. Neural Networks (MLP)

    • MLPClassifier:

      • hidden_layer_sizes=(n1, n2): Number of neurons in hidden layers.
      • activation='relu', 'tanh', 'logistic'.
      • alpha: L2 regularization (higher → more regularization).
      • solver='adam' (default), 'sgd', 'lbfgs'.
    • Overfitting Control:

      • Increase alpha → stronger regularization.
      • Reduce hidden layer size → simpler model.

C. Unsupervised Learning

Key Algorithms & Concepts:

  1. Clustering

    • K-Means:

      • Assigns points to K clusters by minimizing within-cluster variance.
      • n_clusters=K: Number of clusters.
      • labels_: Cluster assignments for each point.
      • cluster_centers_: Coordinates of centroids.
    • Hierarchical Clustering:

      • Linkage Methods:

        • complete (max distance), average, single (min distance), ward (min variance).
  1. Dimensionality Reduction

    • PCA (Principal Component Analysis):

      • Reduces features to n_components principal components.
      • PCA(n_components=2)

D. Model Evaluation

Key Metrics & Concepts:

  1. Confusion Matrix

    • Structure: | | | Predicted 0 | Predicted 1 | |---------------|------------------|------------------| | Actual 0 | True Negative (TN) | False Positive (FP) | | Actual 1 | False Negative (FN) | True Positive (TP) |
Precision=TPTP+FP\text{Precision} = \frac{TP}{TP + FP}
Recall=TPTP+FN\text{Recall} = \frac{TP}{TP + FN}
F1=2×Precision×RecallPrecision+RecallF1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
  1. Regularization

    • L1 (Lasso): Encourages sparsity (some weights = 0).
    • L2 (Ridge): Penalizes large weights.
    • Elastic Net: Combination of L1 + L2.
  1. Bias-Variance Tradeoff

    • High Bias (Underfitting): Model is too simple.
    • High Variance (Overfitting): Model is too complex.
    • Regularization helps reduce variance.

E. Ensemble Methods

Key Concepts:

  1. Bagging (Bootstrap Aggregating)

    • BaggingClassifier: Trains multiple models on random subsets of data.
    • Example:

      BaggingClassifier(base_estimator=KNeighborsClassifier(), n_estimators=10)
    • max_samples=0.5: Each estimator uses 50% of samples.
  1. Random Forest

    • RandomForestClassifier:

      • n_estimators: Number of trees.
      • max_features: Features considered for splits (default=sqrt(n_features)).
      • Diversity: Achieved via random feature subsets and bootstrapping.

F. Text Feature Extraction

Key Concepts:

  1. CountVectorizer

    • Converts text to word-count matrix.
    • fit_transform(corpus) → Returns (n_documents, n_unique_words) matrix.
  1. TF-IDF (Term Frequency-Inverse Document Frequency)

    • Weights words by importance (common words get lower weights).

2. Key Equations

ConceptEquation
Standard Scalingz=x−μσz = \frac{x - \mu}{\sigma}
Max-Abs Scalingxscaled=x∣Xmax∣x_{\text{scaled}} = \frac{x}{|X_{\text{max}}|}
Min-Max Scalingxscaled=x−XminXmax−Xminx_{\text{scaled}} = \frac{x - X_{\text{min}}}{X_{\text{max}} - X_{\text{min}}}
Linear RegressionY=W0+W1X1+⋯+WnXn+ϵY = W_0 + W_1 X_1 + \dots + W_n X_n + \epsilon
Logistic Regression (Sigmoid)σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}
PrecisionPrecision=TPTP+FP\text{Precision} = \frac{TP}{TP + FP}
RecallRecall=TPTP+FN\text{Recall} = \frac{TP}{TP + FN}
F1-ScoreF1=2×Precision×RecallPrecision+RecallF1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
L1 Regularization (Lasso)Loss+λ∑∣wi∣\text{Loss} + \lambda \sum |w_i|
L2 Regularization (Ridge)Loss+λ∑wi2\text{Loss} + \lambda \sum w_i^2
Polynomial Features (Degree 2)[1,x1,x2,x12,x1x2,x22][1, x_1, x_2, x_1^2, x_1 x_2, x_2^2]

Graph 2: Supervised Learning Algorithms

Graph 3: Unsupervised Learning

Graph 4: Model Evaluation & Regularization

Graph 5: Ensemble Methods


4. Exam Tips

  1. Focus Areas:

    • Data Preprocessing: Scaling, encoding, imputation, pipelines.
    • Supervised Learning: Logistic Regression, KNN, SVM, Neural Networks.
    • Unsupervised Learning: K-Means, Hierarchical Clustering, PCA.
    • Model Evaluation: Confusion matrix, precision/recall, regularization.
    • Ensemble Methods: Bagging, Random Forest.
  1. Common Pitfalls:

    • Scaling: Always scale features for KNN, SVM, and neural networks.
    • Regularization: Lower C in LogisticRegression/SVM = stronger regularization.
    • K-Means: Initialize with n_clusters and check labels_/cluster_centers_.
    • PolynomialFeatures: interaction_only=True excludes higher-degree terms for single features.
  1. Code Snippets to Remember: ```python # StandardScaler scaler = StandardScaler() scaled_data = scaler.fit_transform(data)

# K-Means kmeans = KMeans(n_clusters=3) kmeans.fit(data) labels = kmeans.labels_

# Logistic Regression with L1 model = LogisticRegression(penalty='l1', solver='liblinear')

# Pipeline pipe = Pipeline([ ('impute', SimpleImputer()), ('scale', StandardScaler()), ('model', LogisticRegression()) ]) ```


This summary covers 90% of the exam content. Focus on scikit-learn implementations, preprocessing steps, and model evaluation metrics for high scores!