Skip to main content

Unit 3: Classification & Instance-Based Learning

Course - Machine Learning Algorithms (21CSC555J)
Assessment - Continuous Test 2 (CT-2)
Unit - Unit 3: Naïve Bayes & K-Nearest Neighbors
Total Weightage - 40 Marks (Question 1.a: 15 Marks; Question 1.b: 5 Marks; Question 2: 20 Marks)


Question 1.a: Naïve Bayes Spam Filtering (15 Marks)​

info

Question Statement

An email filtering system uses Naïve Bayes to classify messages as Spam or Not Spam. Given the training dataset:

Training Dataset for Spam Classification

EmailContains 'Offer'Contains 'Win'Spam
E1YesYesYes
E2NoYesYes
E3YesNoNo
E4NoNoNo
  • i) Calculate the conditional probabilities (5 marks)
    P(Offer∣Spam)P(\text{Offer} \mid \text{Spam}), P(Win∣Spam)P(\text{Win} \mid \text{Spam}), P(Offer∣NotSpam)P(\text{Offer} \mid \text{NotSpam}), P(Win∣NotSpam)P(\text{Win} \mid \text{NotSpam}).
  • ii) For a new email with "Offer = Yes, Win = Yes", compute (5 marks)
    P(Spam∣Email)P(\text{Spam} \mid \text{Email}) and P(NotSpam∣Email)P(\text{NotSpam} \mid \text{Email})
  • iii) Predict the class and briefly explain the independence assumption. (5 marks)

Solution 1.a​

📝 Exam-Ready Answer (Structured for 15 Marks)​

(i) Calculate Conditional Probabilities (5 Marks)​
  1. Step 1: Dataset Partitioning & Class Totals (1 Mark)

    • Total number of training samples: N=4N = 4
    • Total Spam emails (C=SpamC = \text{Spam}): NSpam=2N_{\text{Spam}} = 2 (Emails: E1, E2)
    • Total Not Spam emails (C=NotSpamC = \text{NotSpam}): NNotSpam=2N_{\text{NotSpam}} = 2 (Emails: E3, E4)
  2. Step 2: General Formula for Maximum Likelihood Conditional Probability (1 Mark) P(Xi=x∣C=c)=Count(Xi=x and C=c)Count(C=c)P(X_i = x \mid C = c) = \frac{\text{Count}(X_i = x \text{ and } C = c)}{\text{Count}(C = c)}

  3. Step 3: Evaluate Conditional Probabilities for Spam Class (1.5 Marks)

    • For feature 'Offer' = Yes: P(Offer=Yes∣Spam)=Count(Offer=Yes and Spam)Count(Spam)=12=0.5P(\text{Offer} = \text{Yes} \mid \text{Spam}) = \frac{\text{Count}(\text{Offer}=\text{Yes} \text{ and } \text{Spam})}{\text{Count}(\text{Spam})} = \frac{1}{2} = \mathbf{0.5} (Email E1 has Offer=Yes; E2 has Offer=No)
    • For feature 'Win' = Yes: P(Win=Yes∣Spam)=Count(Win=Yes and Spam)Count(Spam)=22=1.0P(\text{Win} = \text{Yes} \mid \text{Spam}) = \frac{\text{Count}(\text{Win}=\text{Yes} \text{ and } \text{Spam})}{\text{Count}(\text{Spam})} = \frac{2}{2} = \mathbf{1.0} (Both emails E1 and E2 have Win=Yes)
  4. Step 4: Evaluate Conditional Probabilities for Not Spam Class (1.5 Marks)

    • For feature 'Offer' = Yes: P(Offer=Yes∣NotSpam)=Count(Offer=Yes and NotSpam)Count(NotSpam)=12=0.5P(\text{Offer} = \text{Yes} \mid \text{NotSpam}) = \frac{\text{Count}(\text{Offer}=\text{Yes} \text{ and } \text{NotSpam})}{\text{Count}(\text{NotSpam})} = \frac{1}{2} = \mathbf{0.5} (Email E3 has Offer=Yes; E4 has Offer=No)
    • For feature 'Win' = Yes: P(Win=Yes∣NotSpam)=Count(Win=Yes and NotSpam)Count(NotSpam)=02=0.0P(\text{Win} = \text{Yes} \mid \text{NotSpam}) = \frac{\text{Count}(\text{Win}=\text{Yes} \text{ and } \text{NotSpam})}{\text{Count}(\text{NotSpam})} = \frac{0}{2} = \mathbf{0.0} (Neither E3 nor E4 has Win=Yes)
Conditional Probability Summary Table​
Feature (XiX_i)ValueP(Xi∣Spam)P(X_i \mid \text{Spam})P(Xi∣NotSpam)P(X_i \mid \text{NotSpam})
Contains 'Offer'Yes1/2=0.51/2 = \mathbf{0.5}1/2=0.51/2 = \mathbf{0.5}
Contains 'Win'Yes2/2=1.02/2 = \mathbf{1.0}0/2=0.00/2 = \mathbf{0.0}

(ii) Compute Probabilities for New Email: Xnew=(Offer=Yes,Win=Yes)\mathbf{X}_{\text{new}} = (\text{Offer} = \text{Yes}, \text{Win} = \text{Yes}) (5 Marks)​
  1. Step 1: Compute Prior Class Probabilities (1 Mark) P(Spam)=NSpamN=24=0.5P(\text{Spam}) = \frac{N_{\text{Spam}}}{N} = \frac{2}{4} = \mathbf{0.5} P(NotSpam)=NNotSpamN=24=0.5P(\text{NotSpam}) = \frac{N_{\text{NotSpam}}}{N} = \frac{2}{4} = \mathbf{0.5}

  2. Step 2: State Bayes' Posterior Formula with Conditional Independence (1 Mark) P(C∣X)=P(X∣C)⋅P(C)P(X)=P(Offer=Yes∣C)⋅P(Win=Yes∣C)⋅P(C)P(X)P(C \mid \mathbf{X}) = \frac{P(\mathbf{X} \mid C) \cdot P(C)}{P(\mathbf{X})} = \frac{P(\text{Offer}=\text{Yes} \mid C) \cdot P(\text{Win}=\text{Yes} \mid C) \cdot P(C)}{P(\mathbf{X})}

  3. Step 3: Calculate Unnormalized Joint Likelihoods (1.5 Marks)

    • For class Spam: L(Spam)=P(Offer=Yes∣Spam)×P(Win=Yes∣Spam)×P(Spam)\mathcal{L}(\text{Spam}) = P(\text{Offer}=\text{Yes} \mid \text{Spam}) \times P(\text{Win}=\text{Yes} \mid \text{Spam}) \times P(\text{Spam}) L(Spam)=0.5×1.0×0.5=0.25\mathcal{L}(\text{Spam}) = 0.5 \times 1.0 \times 0.5 = \mathbf{0.25}

    • For class Not Spam: L(NotSpam)=P(Offer=Yes∣NotSpam)×P(Win=Yes∣NotSpam)×P(NotSpam)\mathcal{L}(\text{NotSpam}) = P(\text{Offer}=\text{Yes} \mid \text{NotSpam}) \times P(\text{Win}=\text{Yes} \mid \text{NotSpam}) \times P(\text{NotSpam}) L(NotSpam)=0.5×0.0×0.5=0.0\mathcal{L}(\text{NotSpam}) = 0.5 \times 0.0 \times 0.5 = \mathbf{0.0}

  4. Step 4: Compute Evidence (Marginal Probability P(X)P(\mathbf{X})) (0.5 Marks) P(X)=L(Spam)+L(NotSpam)=0.25+0.0=0.25P(\mathbf{X}) = \mathcal{L}(\text{Spam}) + \mathcal{L}(\text{NotSpam}) = 0.25 + 0.0 = \mathbf{0.25}

  5. Step 5: Normalize to Obtain Final Posterior Probabilities (1 Mark) P(Spam∣Email)=L(Spam)P(X)=0.250.25=1.0(100%)P(\text{Spam} \mid \text{Email}) = \frac{\mathcal{L}(\text{Spam})}{P(\mathbf{X})} = \frac{0.25}{0.25} = \mathbf{1.0} \quad (100\%) P(NotSpam∣Email)=L(NotSpam)P(X)=0.00.25=0.0(0%)P(\text{NotSpam} \mid \text{Email}) = \frac{\mathcal{L}(\text{NotSpam})}{P(\mathbf{X})} = \frac{0.0}{0.25} = \mathbf{0.0} \quad (0\%)


(iii) Class Prediction & Explanation of Independence Assumption (5 Marks)​
  1. Step 1: Class Prediction by Maximum A Posteriori (MAP) Rule (2 Marks) y^=arg⁡max⁡c∈{Spam,NotSpam}P(C=c∣X)\hat{y} = \arg\max_{c \in \{\text{Spam}, \text{NotSpam}\}} P(C = c \mid \mathbf{X}) Since P(Spam∣Email)=1.0>P(NotSpam∣Email)=0.0\text{Since } P(\text{Spam} \mid \text{Email}) = 1.0 > P(\text{NotSpam} \mid \text{Email}) = 0.0 y^=Spam\hat{y} = \text{\textbf{Spam}}

    • Conclusion: The new email is classified as Spam.
  2. Step 2: Formal Statement of Class-Conditional Independence Assumption (1.5 Marks)

    • The Naïve Bayes classifier assumes that all features X1,X2,…,XdX_1, X_2, \dots, X_d are mutually conditionally independent given the class label CC: P(X1,X2,…,Xd∣C)=∏j=1dP(Xj∣C)P(X_1, X_2, \dots, X_d \mid C) = \prod_{j=1}^d P(X_j \mid C)
    • In this problem context, it assumes that the presence of the word 'Offer' is completely independent of the presence of the word 'Win', once we know whether the email is Spam or Not Spam.
  3. Step 3: Real-World Validity & Trade-offs (1.5 Marks)

    • Why it is "Naïve": In natural language, promotional keywords are strongly correlated (e.g., an email containing "Offer" is far more likely to also contain "Win"). Treating them as conditionally independent is mathematically unrealistic.
    • Why it is preferred in practice: Despite this violated assumption, the classifier performs remarkably well because it only needs the correct probability ranking (arg⁡max⁡\arg\max), not perfectly calibrated probabilities. It reduces computational complexity from O(2d)O(2^d) parameters to O(d)O(d) parameters, preventing overfitting on small training corpuses.

Question 1.b: Comparative Analysis of Classifiers on Medical Data (5 Marks)​

info

Question Statement

A data scientist is working on three models for classifying medical test results:

  • KNN (k=5k=5)
  • Gaussian Naïve Bayes
  • SVM with RBF kernel

Assume given is a small dataset with numeric features:

  • a. Which algorithm handles non-linear boundaries best and why? (2 Marks)
  • b. Which algorithm is most sensitive to irrelevant features? (1.5 Marks)
  • c. Which algorithm performs better when data is small and has missing values? (1.5 Marks)

Solution 1.b​

📝 Exam-Ready Answer (Structured for 5 Marks)​

(a) Best Algorithm for Non-Linear Decision Boundaries (2 Marks)​
  • Selected Algorithm: Support Vector Machine (SVM) with RBF (Radial Basis Function) Kernel.
  • Technical Justification:
    1. Kernel Trick: The RBF (Gaussian) kernel mathematically computes inner products in an infinite-dimensional Hilbert feature space: K(x,x′)=exp⁡(−γ∥x−x′∥2)K(\mathbf{x}, \mathbf{x}') = \exp\left( -\gamma \|\mathbf{x} - \mathbf{x}'\|^2 \right)
    2. Linear Hyperplane →\to Non-linear Boundary: A linear separating hyperplane constructed in this infinite-dimensional space maps back to smooth, arbitrarily complex, non-linear decision contours in the original input space.
    3. Superiority over KNN & Gaussian NB: While KNN can form piecewise non-linear boundaries, it suffers from noise and irregular boundary jaggedness. Gaussian Naïve Bayes can only construct linear or quadratic (ellipsoidal) boundaries under normal distributions. SVM with RBF provides the optimal margin and continuous non-linear separation.
(b) Algorithm Most Sensitive to Irrelevant Features (1.5 Marks)​
  • Selected Algorithm: K-Nearest Neighbors (KNN, k=5k=5).
  • Technical Justification:
    1. Uniform Distance Computation: KNN computes spatial proximity (e.g., Euclidean distance) across all DD feature dimensions uniformly: d(x,y)=∑j=1D(xj−yj)2d(\mathbf{x}, \mathbf{y}) = \sqrt{\sum_{j=1}^D (x_j - y_j)^2}
    2. Curse of Dimensionality: Irrelevant or noisy features contribute random variance to the distance sum equally with relevant features. As irrelevant dimensions increase, all pairwise distances converge to the same value (dmax⁡≈dmin⁡d_{\max} \approx d_{\min}), completely destroying the neighborhood structure.
    3. Comparison: SVM learns small or zero weights (αi\alpha_i) for non-informative dimensions, and Naïve Bayes only computes feature-wise marginal products without distance coupling.
(c) Algorithm Performing Better with Small Datasets and Missing Values (1.5 Marks)​
  • Selected Algorithm: Gaussian Naïve Bayes.
  • Technical Justification:
    1. Small Dataset Robustness (High Bias, Low Variance): With few samples, high-capacity models (SVM with RBF) are prone to severe overfitting, and KNN (k=5k=5) suffers from sparse sample density. Gaussian Naïve Bayes requires estimating only two parameters per feature (mean μj\mu_j and variance σj2\sigma_j^2), converging to its asymptotic error much faster with small sample sizes NN.
    2. Native Missing Value Handling (Marginalization): Naïve Bayes naturally handles missing feature values during inference by simply omitting the missing attribute from the conditional probability product: P(xobs∣C)=∏j∈observedP(xj∣C)P(\mathbf{x}_{\text{obs}} \mid C) = \prod_{j \in \text{observed}} P(x_j \mid C) In contrast, standard SVM and KNN cannot evaluate dot products or distance vectors when attributes contain NaN without requiring synthetic imputation.
Comparative Summary Matrix​
Evaluation CriterionKNN (k=5k=5)Gaussian Naïve BayesSVM (RBF Kernel)Winner
Non-Linear BoundaryPiecewise, noisyQuadratic / EllipsoidalInfinite-dimensional projectionSVM (RBF)
Irrelevant FeaturesHighly vulnerable (distance noise)ModerateRobust (max-margin regularization)KNN (Most Sensitive)
Small NN + Missing DataFails distance computationOptimal (rapid convergence + native omission)Fails kernel computationGaussian NB

Question 2: K-Nearest Neighbors Customer Spending Classification (20 Marks)​

info

Question Statement

A company wants to classify new customers as "High Spender" or "Low Spender" based on their income and average monthly spending.

Training data:

CustomerIncome (₹1000s)Spending (₹1000s)Class
C1205Low
C2257Low
C35020High
C45522High
C53010Low
  • (a) For a new customer with Income=40\text{Income} = 40 and Spending=15\text{Spending} = 15, calculate the Euclidean distance from each training point. (5 Marks)
  • (b) Predict the class when K=3K=3. Show all steps clearly. (5 Marks)
  • (c) Recalculate distances using the Manhattan distance metric and compare the result. (5 Marks)
  • (d) Explain: How feature scaling/normalization affects KNN results, and what happens when KK is too small or too large. (3 Marks)
  • (e) Mention one real-world application where KNN is used and why it is preferred there. (2 Marks)

Solution 2​

📝 Exam-Ready Answer (Structured for 20 Marks)​

Let the query point for the new customer be: Xnew=(x1,x2)=(40,15)\mathbf{X}_{\text{new}} = (x_1, x_2) = (40, 15) where x1x_1 represents Income (in ₹1000s) and x2x_2 represents Spending (in ₹1000s).


(a) Euclidean Distance Calculation (5 Marks)​
  1. Step 1: Formula Definition (1 Mark) The Euclidean distance (L2L_2 norm) between Xnew=(40,15)\mathbf{X}_{\text{new}} = (40, 15) and training point Xi=(xi1,xi2)\mathbf{X}_i = (x_{i1}, x_{i2}) is: dE(Xnew,Xi)=(40−xi1)2+(15−xi2)2d_E(\mathbf{X}_{\text{new}}, \mathbf{X}_i) = \sqrt{(40 - x_{i1})^2 + (15 - x_{i2})^2}

  2. Step 2: Individual Distance Computations (3 Marks)

    • For Customer C1 (20,5)(20, 5): dE(X,C1)=(40−20)2+(15−5)2=202+102=400+100=500≈22.36d_E(\mathbf{X}, C_1) = \sqrt{(40 - 20)^2 + (15 - 5)^2} = \sqrt{20^2 + 10^2} = \sqrt{400 + 100} = \sqrt{500} \approx \mathbf{22.36}

    • For Customer C2 (25,7)(25, 7): dE(X,C2)=(40−25)2+(15−7)2=152+82=225+64=289=17.00d_E(\mathbf{X}, C_2) = \sqrt{(40 - 25)^2 + (15 - 7)^2} = \sqrt{15^2 + 8^2} = \sqrt{225 + 64} = \sqrt{289} = \mathbf{17.00}

    • For Customer C3 (50,20)(50, 20): dE(X,C3)=(40−50)2+(15−20)2=(−10)2+(−5)2=100+25=125≈11.18d_E(\mathbf{X}, C_3) = \sqrt{(40 - 50)^2 + (15 - 20)^2} = \sqrt{(-10)^2 + (-5)^2} = \sqrt{100 + 25} = \sqrt{125} \approx \mathbf{11.18}

    • For Customer C4 (55,22)(55, 22): dE(X,C4)=(40−55)2+(15−22)2=(−15)2+(−7)2=225+49=274≈16.55d_E(\mathbf{X}, C_4) = \sqrt{(40 - 55)^2 + (15 - 22)^2} = \sqrt{(-15)^2 + (-7)^2} = \sqrt{225 + 49} = \sqrt{274} \approx \mathbf{16.55}

    • For Customer C5 (30,10)(30, 10): dE(X,C5)=(40−30)2+(15−10)2=102+52=100+25=125≈11.18d_E(\mathbf{X}, C_5) = \sqrt{(40 - 30)^2 + (15 - 10)^2} = \sqrt{10^2 + 5^2} = \sqrt{100 + 25} = \sqrt{125} \approx \mathbf{11.18}

  3. Step 3: Distance Summary Table (1 Mark)

CustomerIncome (xi1x_{i1})Spending (xi2x_{i2})Class(40−xi1)2(40-x_{i1})^2(15−xi2)2(15-x_{i2})^2Sum of SquaresEuclidean Distance (dEd_E)
C1205Low400100500≈22.36\approx \mathbf{22.36}
C2257Low2256428917.00\mathbf{17.00}
C35020High10025125≈11.18\approx \mathbf{11.18}
C45522High22549274≈16.55\approx \mathbf{16.55}
C53010Low10025125≈11.18\approx \mathbf{11.18}

(b) Predict Class When K=3K=3 (5 Marks)​
  1. Step 1: Rank Distances in Ascending Order (1.5 Marks)
RankCustomerEuclidean Distance (dEd_E)Class LabelIncluded in K=3K=3?
1C311.1811.18HighYes
2C511.1811.18LowYes
3C416.5516.55HighYes
4C217.0017.00LowNo
5C122.3622.36LowNo
  1. Step 2: Identify the K=3K=3 Nearest Neighbors (1.5 Marks)

    • Nearest Neighbor 1: C3 with dE=11.18d_E = 11.18   ⟹  \implies Class = High
    • Nearest Neighbor 2: C5 with dE=11.18d_E = 11.18   ⟹  \implies Class = Low
    • Nearest Neighbor 3: C4 with dE=16.55d_E = 16.55   ⟹  \implies Class = High
  2. Step 3: Majority Voting & Posterior Probability (1 Mark)

    • Vote count for Class High: 22 (from C3, C4)
    • Vote count for Class Low: 11 (from C5)
    • Empirical class probability: P(High∣X)=23≈66.67%P(\text{High} \mid \mathbf{X}) = \frac{2}{3} \approx 66.67\% P(Low∣X)=13≈33.33%P(\text{Low} \mid \mathbf{X}) = \frac{1}{3} \approx 33.33\%
  3. Step 4: Final Prediction Statement (1 Mark)

    • By majority voting rule (2>12 > 1), the new customer with Income=40\text{Income} = 40 and Spending=15\text{Spending} = 15 is predicted as: y^=High Spender\hat{y} = \text{\textbf{High Spender}}

(c) Recalculate Distances Using Manhattan Metric & Compare (5 Marks)​
  1. Step 1: Formula Definition (1 Mark) The Manhattan distance (L1L_1 norm / Taxicab distance) is: dM(Xnew,Xi)=∣40−xi1∣+∣15−xi2∣d_M(\mathbf{X}_{\text{new}}, \mathbf{X}_i) = \lvert 40 - x_{i1} \rvert + \lvert 15 - x_{i2} \rvert

  2. Step 2: Individual Computations (2 Marks)

    • For C1 (20,5)(20, 5): dM=∣40−20∣+∣15−5∣=20+10=30d_M = \lvert 40 - 20 \rvert + \lvert 15 - 5 \rvert = 20 + 10 = \mathbf{30}
    • For C2 (25,7)(25, 7): dM=∣40−25∣+∣15−7∣=15+8=23d_M = \lvert 40 - 25 \rvert + \lvert 15 - 7 \rvert = 15 + 8 = \mathbf{23}
    • For C3 (50,20)(50, 20): dM=∣40−50∣+∣15−20∣=10+5=15d_M = \lvert 40 - 50 \rvert + \lvert 15 - 20 \rvert = 10 + 5 = \mathbf{15}
    • For C4 (55,22)(55, 22): dM=∣40−55∣+∣15−22∣=15+7=22d_M = \lvert 40 - 55 \rvert + \lvert 15 - 22 \rvert = 15 + 7 = \mathbf{22}
    • For C5 (30,10)(30, 10): dM=∣40−30∣+∣15−10∣=10+5=15d_M = \lvert 40 - 30 \rvert + \lvert 15 - 10 \rvert = 10 + 5 = \mathbf{15}
  3. Step 3: Metric Comparison Table (1 Mark)

CustomerClassEuclidean Distance (dEd_E)Euclidean RankManhattan Distance (dMd_M)Manhattan Rank
C3High11.1811.181 (Tie)15151 (Tie)
C5Low11.1811.181 (Tie)15151 (Tie)
C4High16.5516.55322223
C2Low17.0017.00423234
C1Low22.3622.36530305
  1. Step 4: Analytical Comparison & Conclusion (1 Mark)
    • Set Invariance: The set of K=3K=3 nearest neighbors under Manhattan distance is identical: {C3,C5,C4}\{C_3, C_5, C_4\}.
    • Tally & Outcome: The majority vote remains 2 High2 \text{ High} vs 1 Low1 \text{ Low}.
    • Conclusion: The prediction remains unchanged as High Spender. This demonstrates that the local neighborhood around query point (40,15)(40, 15) is topologically stable across both L1L_1 and L2L_2 geometric norms.

(d) Theoretical Analysis: Feature Scaling & Choice of K (3 Marks)​
  1. Impact of Feature Scaling / Normalization (1.5 Marks)

    • Problem of Dominance: Distance metrics (Euclidean and Manhattan) assume all feature axes are isotropic (equal weight per numeric unit). If one feature has a vastly larger scale (e.g., Annual Income in raw rupees: ₹40,000 to ₹55,000) compared to monthly spending (₹5 to ₹22), the difference in income will mathematically dominate the distance sum: (40,000−20,000)2≫(15−5)2(40,000 - 20,000)^2 \gg (15 - 5)^2 This effectively reduces the 2D feature space to a 1D space, ignoring the spending feature.
    • Remedy: Standardizing features using Min-Max Normalization (x′=x−xmin⁡xmax⁡−xmin⁡∈[0,1]x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}} \in [0, 1]) or Z-Score Standardization (z=x−μσz = \frac{x - \mu}{\sigma}) ensures every feature contributes proportionally to the distance calculation.
  2. Effects of Parameter KK Selection (1.5 Marks)

Parameter SettingModel ComplexityBias vs VarianceRisk / Behavior
KK is too small (K=1K = 1)Overly complex, jagged decision boundariesLow Bias, High VarianceHighly vulnerable to training noise and outliers; easily leads to Overfitting.
KK is too large (K→NK \to N)Overly smooth, rigid boundariesHigh Bias, Low VarianceIgnores local spatial structure; degenerates into predicting the global majority class (Underfitting).
  • Rule of Thumb: Choose an odd value for KK in binary classification to prevent ties, commonly setting K≈NK \approx \sqrt{N} and tuning via cross-validation.

(e) Real-World Application of KNN (2 Marks)​
  1. Application Domain (1 Mark):

    • E-Commerce & Streaming Collaborative Filtering Recommender Systems (e.g., Amazon product suggestions, Spotify playlist recommendations, or Netflix movie matching).
  2. Why KNN is Preferred There (1 Mark):

    • Instance-Based Simplicity (Lazy Learning): It requires no expensive training phase. New users and items can be ingested dynamically in real time without retraining a global model.
    • Natural Neighborhood Intuition: Recommending items liked by users with similar consumption profiles (nearest neighbors in feature embedding space) is highly interpretable, intuitive, and effective without requiring complex parametric assumptions.