LearnQuestion bank

Compare a linear SVM with logistic regression (loss, outputs, behaviour on separable data) and explain how the kernel trick lets an SVM learn non-linear boundaries.

ResearchTechnicalEasy

Theme reported publicly: Google DeepMind

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Hinge loss vs log loss: SVM penalises only violations of the margin; logistic regression penalises probabilistic miscalibration.
  • Outputs: SVM gives a margin/decision score, not calibrated probabilities; logistic regression gives sigmoid probabilities.
  • Separable data: unregularised logistic weights diverge; hard-margin SVM has a finite max-margin solution.
  • SVM solution is determined by support vectors only.
  • Kernel trick replaces x^T x’ with k(x,x’) for Mercer kernels such as RBF; kernel matrix costs O(n^2); logistic regression can be kernelised too but loses sparsity.

In full

The core difference is the objective: a linear SVM minimises hinge loss, max(0, 1 - y f(x)), so it only cares about getting the margin right, while logistic regression minimises log loss, -[y log p + (1-y) log(1-p)], so it cares about calibrated probabilities. That is why an SVM outputs a margin/decision score sign(w^T x + b), not a probability, whereas logistic regression outputs p = sigmoid(w^T x + b); if you need probabilities from an SVM, Platt scaling fits a logistic model on the SVM scores. On separable data, unregularised logistic regression has no finite MLE and its weights grow without bound, while a hard-margin SVM has a finite maximum-margin solution; with fixed regularisation logistic regression stays finite but can still become large. The SVM solution depends only on the support vectors, since only those points have nonzero dual coefficients. The kernel trick lets an SVM learn non-linear boundaries by replacing inner products in a high-dimensional feature space with k(x, x’), using Mercer kernels such as RBF, k(x,x’) = exp(-gamma ||x-x’||^2), at the cost of an O(n^2) kernel matrix. Logistic regression can be kernelised in the same way, but its solution is generally not sparse, whereas the SVM’s depends only on the support vectors.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Hinge loss vs log loss.
  • An SVM gives margins, not probabilities (Platt scaling can calibrate).
  • Logistic-regression weights grow without bound on separable data unless regularised.
  • The SVM solution depends only on the support vectors.
  • Kernel trick: inner products in feature space via k(x, x′) (Mercer kernels, RBF); the kernel matrix costs O(n²).

Common mistakes

  • Saying logistic regression cannot be kernelised.
  • Saying SVM outputs are calibrated probabilities.