When would you choose a linear SVM solved in the primal over a kernel SVM solved in the dual?

Quick Overview

Asks when a linear SVM trained in the primal is the better choice than a kernel SVM trained in the dual. It tests how you reason about training and prediction cost as data grows, sparse versus dense features, nonlinear boundaries, and kernel approximations.

When would you choose a linear SVM solved in the primal over a kernel SVM solved in the dual?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

When would you choose a linear SVM solved in the primal over a kernel SVM solved in the dual? ```hint Compare the costs Write down how training time, memory and prediction time scale with the number of samples $n$ and the number of features $d$ for each approach. ``` ```hint Think about the data Consider which kinds of data are already close to linearly separable, and what a kernel lets you express that a fixed feature vector does not. ``` ### What a Strong Answer Covers - How training cost, memory and prediction cost scale with $n$, $d$ and sparsity for each approach. - The kinds of data where a linear boundary is usually enough and where a kernel adds real accuracy. - Other practical needs that favor one side, such as interpretability, online updates, latency and custom kernels. - A middle ground that approximates a kernel at linear cost. - A sensible way to decide, starting from a baseline and validation results. ### Follow-up Questions - How do random Fourier features approximate an RBF kernel, and how many features would you need? - A linear SVM can also be solved in its own dual. When is that faster than a primal solver? - How does the number of support vectors affect the latency of a kernel SVM in production? - How would you tune $C$ and the RBF parameter $\gamma$, and what happens at their extremes?

Overview: Asks when a linear SVM trained in the primal is the better choice than a kernel SVM trained in the dual. It tests how you reason about training and prediction cost as data grows, sparse versus dense features, nonlinear boundaries, and kernel approximations.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

When would you choose a linear SVM solved in the primal over a kernel SVM solved in the dual?

What a Strong Answer Covers Guidance

  • How training cost, memory and prediction cost scale with nn , dd and sparsity for each approach.
  • The kinds of data where a linear boundary is usually enough and where a kernel adds real accuracy.
  • Other practical needs that favor one side, such as interpretability, online updates, latency and custom kernels.
  • A middle ground that approximates a kernel at linear cost.
  • A sensible way to decide, starting from a baseline and validation results.

Follow-up Questions Guidance

  • How do random Fourier features approximate an RBF kernel, and how many features would you need?
  • A linear SVM can also be solved in its own dual. When is that faster than a primal solver?
  • How does the number of support vectors affect the latency of a kernel SVM in production?
  • How would you tune CC and the RBF parameter γ\gamma , and what happens at their extremes?