Kernel Methods — Interview Grill

35 questions on kernels and kernel SVM. Drill until you can answer 25+ cold.


A. Foundations

1. What's the kernel trick? A kernel function computes an inner product in some (possibly infinite-dimensional) feature space without ever computing the features explicitly. Replace with in any algorithm that only accesses data via inner products.

2. State Mercer's theorem. A function is a valid kernel iff: (a) symmetric (), (b) positive semi-definite (the kernel matrix has all eigenvalues for any finite set). Equivalently: there exists a feature map with .

3. Why does PSD matter? PSD guarantees the kernel corresponds to a real inner product in some feature space. Non-PSD "kernels" don't correspond to any feature space — methods built on them lose their theoretical grounding (though sometimes work empirically, like sigmoid).

4. Why is the kernel trick useful? Allows non-linear methods that operate in high-dimensional feature spaces without explicit computation. Linear method + kernel = non-linear method.


B. Specific kernels

5. Linear kernel? . Just dot product. Equivalent to no kernel — used as a baseline.

6. Polynomial kernel? . Implicit feature space contains all monomials up to degree . For : includes products like .

7. RBF (Gaussian) kernel? . Most popular. Infinite-dimensional implicit feature space. controls bandwidth.

8. Why is RBF infinite-dimensional? Factor . Taylor-expand the cross term: . Each equals an inner product of all degree- polynomial features of and — so RBF is an inner product over polynomial features of all degrees, hence infinite-dim.

9. Cosine kernel? . Normalized inner product. Used in NLP/IR.

10. Sigmoid kernel? . Inspired by NN. Not always PSD, but used in practice.


C. Kernel SVM

11. SVM primal formulation?

Hinge loss + L2 penalty. controls margin softness.

12. SVM dual formulation?

subject to . Decision function: .

13. Why does the dual enable kernels? The dual only accesses data through inner products . Replace with — kernel SVM. Primal can't be kernelized directly because would live in the implicit feature space (infinite-dim for RBF).

14. What are support vectors? Training points with non-zero in the dual. Geometrically: points on or inside the margin. Decision function depends only on them.

15. Why are support vectors interesting? Sparsity: most , so the model only "remembers" support vectors. Inference: . Also: support vectors are robust — adding non-SV points doesn't change the model.

16. What does control in SVM? Soft-margin parameter. Large : hard margin, less regularization, can overfit. Small : more slack allowed, more regularization, more support vectors.

17. What does in RBF SVM control? Bandwidth. Small : smooth decision boundary, low complexity. Large : wiggly boundary, high complexity, overfitting risk.

18. How do you tune SVM hyperparameters? Grid search over (log-scale, e.g., to ) and (also log-scale). Use cross-validation. SVMs are notoriously sensitive to these choices.


D. Other kernel methods

19. Kernel ridge regression? with . Closed-form. Kernel version of linear ridge.

20. What's a Gaussian process? Bayesian extension of kernel ridge. . Posterior given data is Gaussian with mean and variance from kernel structure. Provides uncertainty estimates.

21. Kernel PCA? PCA in feature space via the kernel trick. Compute kernel matrix; eigendecompose; extract top components. Useful for non-linear dimensionality reduction.

22. Kernel k-means? K-means in feature space. Equivalent to spectral clustering for some kernels. Cluster centers are linear combinations of .


E. Theory and RKHS

23. What's an RKHS? Reproducing Kernel Hilbert Space. A function space where each kernel evaluation is a function in , and inner product — the reproducing property.

24. Why does RKHS matter? Provides a unified theoretical framework for kernel methods. Functions learned by SVM, kernel ridge, GP all live in the RKHS. Regularization with explains why kernel methods don't overfit despite operating in infinite-dim spaces.

25. What's the representer theorem? For many regularized kernel methods, the optimal solution has the form — i.e., a linear combination of kernel evaluations at training points. This is why kernel methods are tractable: the solution is always finite-dimensional.


F. Kernels vs deep learning

26. Why did kernels lose to deep learning? memory and training. Fixed kernels (no representation learning). Deep learning scales linearly and learns features end-to-end.

27. Where do kernels still win? Small data (). Bayesian uncertainty (GPs). Theoretical analysis (NTK). Tabular tasks where SVM-RBF is the right capacity.

28. What's the Neural Tangent Kernel (NTK)? Jacot et al. 2018. In the infinite-width limit, deep NNs behave as kernel ridge regression with the NTK: . Bridges kernels and deep learning theoretically.

29. NTK in practice? Theoretical lens. Real NNs at finite width and after training don't behave purely as NTK — feature learning happens. NTK is useful for theory, less for practice.


G. Connection to attention

30. Is attention a kernel? Yes, conceptually. Attention computes — a query attends to keys via a kernel-like similarity, then weighted-averages values. The "kernel" is learned via .

31. What's the difference between attention and classical kernels? Classical kernels are fixed (you choose RBF, polynomial, etc.). Attention is learned — the similarity function depends on which the model trains. This makes attention task-adaptive, classical kernels not.

32. Implications of viewing attention as kernel? Theoretical unification. Attention can be analyzed using kernel-method tools. Recent research uses kernel theory to understand transformer behavior. Frontier-lab interview-relevant.


H. Subtleties

33. Why does kernel SVM need to scale features? RBF and polynomial kernels are sensitive to feature scales. depends on raw feature magnitudes. Standardize or normalize features before fitting.

34. Curse of dimensionality for kernels? In high-dim spaces, distances become uniform (all points become equidistant). RBF kernel can degenerate. Kernels work best at moderate dimensionality with enough data per dimension.

35. Can you combine kernels? Yes. Sum, product, weighted combination, etc. of valid kernels are valid kernels. "Multiple kernel learning" optimizes the combination weights.


Quick fire

36. RBF formula? . 37. Polynomial degree typical? 2 or 3. 38. SVM dual scales as? memory, time. 39. Mercer's conditions? Symmetric + PSD. 40. Connection to attention? Attention = learned kernel.


Self-grading

If you can't answer 1-15, you don't know kernels. If you can't answer 16-30, you'll struggle on classical ML interviews involving SVM. If you can't answer 31-40, frontier-lab interviews on kernel-attention connections will go past you.

Aim for 25+/40 cold.