What does the Gram matrix represent during SVM training?

Quick Overview

Asks what the Gram matrix of pairwise kernel values represents when training a support vector machine. Tests understanding of the SVM dual problem, the positive semi-definite requirement, feature-space geometry, RBF hyperparameter effects and the memory cost of kernel methods.

What does the Gram matrix represent during SVM training?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Consider a kernel SVM trained on $n$ labeled points. What does the Gram matrix represent during SVM training? ```hint Look at the dual Write the SVM dual problem and check where the training inputs $x_i$ appear in it. ``` ```hint Read one entry, then the whole matrix Ask what $K(x_i, x_j)$ tells you about two points in feature space, and what the full matrix tells you about the dataset and the kernel settings. ``` ### What a Strong Answer Covers - What each entry of the matrix is, and that the dual sees the data only through it - Its role in the dual quadratic program - Why it has to be positive semi-definite - What it reveals about the kernel's hyperparameters - Its memory and compute cost, and how solvers cope with it ### Follow-up Questions - What happens during training if the kernel's Gram matrix is not positive semi-definite? - How does prediction use the kernel, and what shape of matrix do you pass to `SVC(kernel='precomputed')` at predict time? - The Gram matrix for a million training points does not fit in memory. What would you do? - For a linear kernel, how does the Gram matrix relate to the data matrix, and when is solving the primal cheaper?

Overview: Asks what the Gram matrix of pairwise kernel values represents when training a support vector machine. Tests understanding of the SVM dual problem, the positive semi-definite requirement, feature-space geometry, RBF hyperparameter effects and the memory cost of kernel methods.

Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Consider a kernel SVM trained on nn labeled points. What does the Gram matrix represent during SVM training?

What a Strong Answer Covers Guidance

  • What each entry of the matrix is, and that the dual sees the data only through it
  • Its role in the dual quadratic program
  • Why it has to be positive semi-definite
  • What it reveals about the kernel's hyperparameters
  • Its memory and compute cost, and how solvers cope with it

Follow-up Questions Guidance

  • What happens during training if the kernel's Gram matrix is not positive semi-definite?
  • How does prediction use the kernel, and what shape of matrix do you pass to SVC(kernel='precomputed') at predict time?
  • The Gram matrix for a million training points does not fit in memory. What would you do?
  • For a linear kernel, how does the Gram matrix relate to the data matrix, and when is solving the primal cheaper?