SVM, Naive Bayes & Probabilistic Models
Level 2 — Recall (Definitions, Standard Problems, Short Derivations)
Time Limit: 30 minutes Total Marks: 40
Q1. Define the maximum margin in the context of a Support Vector Machine. For a hyperplane , write the expression for the geometric margin between the two supporting hyperplanes. (3 marks)
Q2. State the difference between a hard margin and a soft margin SVM classifier. Give one situation where a soft margin is preferred. (4 marks)
Q3. Explain the kernel trick. Why does it allow a linear SVM algorithm to produce non-linear decision boundaries without explicitly computing the high-dimensional feature mapping? (4 marks)
Q4. Write the mathematical form of the following kernels: (a) linear, (b) polynomial of degree , (c) RBF (Gaussian). (3 marks)
Q5. Describe the effect of the hyperparameters and (in an RBF-kernel SVM). State what happens to the model as each is increased. (4 marks)
Q6. What are support vectors? In a trained SVM, how do they relate to the decision boundary, and why does removing a non-support-vector point not change the model? (4 marks)
Q7. State the Naive Bayes assumption. Using Bayes' theorem, write the classification rule (posterior proportionality) for predicting class given features . (4 marks)
Q8. A Gaussian Naive Bayes model estimates for a continuous feature using a Gaussian. For a class with mean and variance , compute the likelihood . Give the formula and the numeric value. (5 marks)
Q9. Explain Laplace (add-one) smoothing in Multinomial Naive Bayes. A word appears 0 times in a class with total word count 40 and vocabulary size 10. Compute the smoothed probability of that word. (4 marks)
Q10. Briefly describe how Naive Bayes is applied to text classification. State one difference between Multinomial and Bernoulli Naive Bayes in this setting. (5 marks)
End of Paper
Answer keyMark scheme & solutions
Q1. (3 marks)
- Maximum margin = the largest possible distance (gap) between the separating hyperplane and the nearest data points of either class. (1)
- SVM chooses the hyperplane that maximizes this margin for best generalization. (1)
- Geometric margin between the two supporting hyperplanes : (1)
Q2. (4 marks)
- Hard margin: requires all points to be correctly classified with no violations; only works if data is linearly separable. (1.5)
- Soft margin: introduces slack variables allowing some misclassifications/margin violations; minimizes . (1.5)
- Soft margin preferred when data is noisy or not perfectly linearly separable (avoids overfitting to outliers). (1)
Q3. (4 marks)
- The kernel trick replaces the inner product in the SVM dual with a kernel function . (2)
- Since the SVM only needs dot products, computes the similarity in the high-dimensional space without explicitly mapping to . (1)
- This makes non-linear boundaries feasible/efficient even when is very high (or infinite) dimensional. (1)
Q4. (3 marks) — 1 mark each
- (a) Linear:
- (b) Polynomial:
- (c) RBF:
Q5. (4 marks)
- controls the trade-off between margin width and classification error. (1)
- Large → penalizes misclassification heavily → narrower margin, less regularization, risk of overfitting. (1)
- controls the reach/influence of a single training point in RBF. (1)
- Large → each point has small radius of influence → complex, wiggly boundary → overfitting; small → smoother boundary. (1)
Q6. (4 marks)
- Support vectors are the training points lying on the margin boundaries (or, in soft-margin, violating them) — i.e., the points closest to / defining the decision boundary. (2)
- The optimal is a linear combination of only the support vectors (). (1)
- Non-support vectors have , so removing them leaves and unchanged. (1)
Q7. (4 marks)
- Naive Bayes assumption: features are conditionally independent given the class. (2)
- Bayes rule: . (1)
- Classification rule: (denominator constant, dropped). (1)
Q8. (5 marks)
- Formula: (2)
- Substitute : exponent . (1)
- Prefactor . (1)
- . (1)
Q9. (4 marks)
- Laplace smoothing adds a count of 1 (α=1) to every word to avoid zero probabilities: (2)
- Substitute: count=0, , : (2)
Q10. (5 marks)
- Text is converted to features (bag-of-words / token counts / presence). (1)
- Compute over document tokens; predict the class with highest posterior (log-space to avoid underflow). (2)
- Difference: Multinomial uses word frequency counts (how many times a word occurs); Bernoulli uses binary presence/absence of words and explicitly models non-occurrence. (2)
[
{"claim":"Q8: Gaussian likelihood at x=8, mu=6, var=4 ≈ 0.1210",
"code":"mu=6; var=4; x=8; val=1/sqrt(2*pi*var)*exp(-(x-mu)**2/(2*var)); result = abs(float(val)-0.1210) < 0.001"},
{"claim":"Q8: exponent term equals -0.5",
"code":"mu=6; var=4; x=8; e=-(x-mu)**2/(2*var); result = e == Rational(-1,2)"},
{"claim":"Q9: Laplace smoothed prob = 1/50 = 0.02",
"code":"p=(0+1)/(40+10); result = p == Rational(1,50)"},
{"claim":"Q1: margin between w.x+b=±1 is 2/||w||",
"code":"w=symbols('wn', positive=True); margin=2/w; result = simplify(margin - 2/w)==0"}
]