Solution:
1A.
a. Prediction of Customer Purchase
Type: Supervised Learning (Classification)
• Justification: The goal is to predict a specific outcome (purchase vs. no purchase) based on
historical data. Since the platform likely has past records of customer behavior paired with
the final result, the model is "supervised" by these labels to learn the boundary between a
buyer and a browser.
b. Discovering Electricity Consumption Patterns
Type: Unsupervised Learning (Clustering/Association)
• Justification: The agency isn't looking for a specific "target" value; they are looking for
hidden structures or anomalies within the data. By using unsupervised techniques, the
algorithm can group similar usage behaviors together without needing prior labels, revealing
"previously unknown" trends or peak-usage groups.
c. Robot Navigating an Unfamiliar Environment
Type: Reinforcement Learning (RL)
• Justification: This scenario involves an agent (the robot) interacting with an environment.
There is no static dataset to learn from; instead, the robot performs actions and receives
feedback in the form of rewards (reaching a goal) or penalties (hitting a wall). It learns an
optimal policy through trial and error.
d. Medical Image Dataset with Limited Labels
Type: Semi-Supervised Learning
• Justification: This is the classic use case for semi-supervised learning, which bridges the gap
between supervised and unsupervised methods.
• The model uses the small labeled dataset to understand the basic features of the
diseases.
• It then leverages the large unlabeled dataset to gain a better understanding of the
overall data distribution and improve its accuracy without requiring expensive
manual labeling by doctors for every single image.
1B.
Slow Convergence in Gradient Descent: For models like Linear/Logistic Regression or Neural
Networks, the cost function becomes an elongated, "stretched" bowl. The gradient descent steps will
oscillate (jump back and forth) wildly, requiring a much smaller learning rate and many more
iterations to reach the global minimum.
Dominance of Large-Scale Features: In distance-based algorithms like k-Nearest Neighbors (k-NN) or
Clustering, the distance calculation is dominated by the feature with the largest numerical range.
Biased Regularization: If you use Ridge or Lasso regression, the penalty is applied to the magnitude
of the coefficients. Features with small scales (like age) will naturally have larger coefficients to
compensate, making them more likely to be unfairly penalized or "shrunk" to zero by the regularizer.
In this case , Standardization (Z-score Normalization) is typically the most robust choice.
2A
Solution:
Step 1: Mean Centering the Data
Compute mean of each feature:
2+3+4+5+6
𝜇𝑥1 = =4
5
1+2+3+4+5
𝜇𝑥2 = =3
5
Subtract the mean from each observation:
Observation 𝑥1 − 𝜇𝑥1 𝑥2 − 𝜇𝑥2
1 -2 -2
2 -1 -1
3 0 0
4 1 1
5 2 2
Let the centered data matrix be:
−2 −2
−1 −1
𝑋= 0 0
1 1
[2 2]
Step 2: Compute Covariance Matrix
The covariance matrix is:
1
Σ= 𝑋𝑇 𝑋
𝑛−1
10 10
𝑋𝑇 𝑋 = [ ]
10 10
2.5 2.5
Σ=[ ]
2.5 2.5
Step 3: Compute Eigenvalues and Eigenvectors
Solve:
∣ Σ − 𝜆𝐼 ∣= 0
2.5 − 𝜆 2.5
∣ ∣= 0
2.5 2.5 − 𝜆
(2.5 − 𝜆)2 − (2.5)2 = 0
𝜆1 = 5, 𝜆2 = 0
Eigenvectors
For 𝜆1 = 5:
1
(Σ − 5𝐼)𝑣 = 0 ⇒ 𝑣1 = [ ]
1
Normalized eigenvector:
1 1
𝑢1 = [ ]
√2 1
For 𝜆2 = 0:
1 1 1
𝑣2 = [ ] ⇒ 𝑢2 = [ ]
−1 √2 −1
Step 4: Select Principal Components
Eigenvalues represent variance:
Component Eigenvalue Variance %
PC1 5 100%
PC2 0 0%
We select PC1 only.
Step 5: Project Data onto PC1
Projection formula:
𝑍 = 𝑋𝑢1
−2 −2 −2√2
−1 −1 1 −√2
1
𝑍= 0 0 ⋅ [ ]= 0
1
1 1 √2 √2
[2 2] [ 2√2 ]
2B
Solution:
3A
Bias is the Error due to Underfitting, High Bias occurs when the model is too simple.
Variance is the Error due to Overfitting. High Variance occurs when the model is overly complex (e.g.,
a high-degree polynomial). It "memorizes" the noise in the training data rather than the underlying
pattern, leading to poor performance on new, unseen data.
The Tradeoff Curve
This graph shows how the total error of a model changes as its complexity increases.
• On the left (Underfitting): The model is too simple, resulting in High Bias.
• On the right (Overfitting): The model is too complex, resulting in High Variance.
• The Center: This represents the "Sweet Spot" where the total error is minimized.
3B
Regularization is more preferred over feature selection here because all features are important here.
Feature selection is "harsh" because it throws away information by setting parameters to zero.
Regularisation is "gentler" because it keeps all features but shrinks the values of the parameters to
reduce their impact, which is useful if all features are relevant.
4A
Smaller K gives low bias, high variance; larger K gives high bias, low variance.
4B
5A.
To calculate Precision and Recall, we first need to determine the counts of True Positives (TP), False
Positives (FP), and False Negatives (FN) for each threshold.
Given Data
• Actual Labels: [1, 0, 1, 0, 1, 1, 1, 0]
• Predicted Probabilities: [0.8, 0.6, 0.7, 0.4, 0.9, 0.3, 0.95, 0.2]
1. Calculation for Threshold = 0.8
At this threshold, a prediction is 1 if the probability is >= 0.8, and 0 otherwise.
• Predicted Labels: [1, 0, 0, 0, 1, 0, 1, 0]
• True Positives (TP): 3 (Instances 1, 5, 7 where Actual=1 and Pred=1)
• False Positives (FP): 0 (No instances where Actual=0 and Pred=1)
• False Negatives (FN): 2 (Instances 3, 6 where Actual=1 and Pred=0)
Metrics:
• Precision = {TP}/{TP + FP} = {3}/{3 + 0} = 1.0 (100%)
• Recall = {TP/}{TP + FN} = {3}/{3 + 2} = {3}/{5} = 0.6 (60%)
2. Calculation for Threshold = 0.4
At this threshold, a prediction is 1 if the probability is >= 0.4, and 0 otherwise.
• Predicted Labels: [1, 1, 1, 1, 1, 0, 1, 0]
• True Positives (TP): 4 (Instances 1, 3, 5, 7 where Actual=1 and Pred=1)
• False Positives (FP): 2 (Instances 2, 4 where Actual=0 and Pred=1)
• False Negatives (FN): 1 (Instance 6 where Actual=1 and Pred=0)
Metrics:
• Precision = {TP}/{TP + FP} = {4}/{4 + 2} = {2}/{3} = 0.667 (66.67%)
• Recall = {TP}/{TP + FN} = 4/{4 + 1} = {4}/{5} = 0.8 (80%)
5B
A.
ROC is a graphical plot showing the performance of a classifier at different classification thresholds
with FPR at x-axis and TPR at y-axis. top-left corner → Better model.
AUC means area under the curve ROC. It means aggregate performance across all possible
classification thresholds.
AUC-1 implies perfectly right model.
AUC – 0.5 implies model is just randomly guessing, it has no classification ability.
AUC – 0 implies perfectly wrong model. It classifies -ve as +ve and +ve as -ve.
B.
Feature selection → Choose the best columns
Feature extraction → Create new columns from existing ones
Example
Dataset features:
• Age
• Salary
• Height
• Weight
• City
Feature selection may keep:
• Age
• Salary
• Weight
Example
Two features:
• Height
• Weight
Feature extraction may create:
• BMI