Diagnose an RBF SVM with near-perfect training accuracy, poor validation and nearly all points as support vectors

Quick Overview

Asks how to diagnose and fix an RBF-kernel SVM that fits the training set almost perfectly, generalizes poorly and keeps nearly every training point as a support vector. Tests understanding of the gamma and C hyperparameters, feature scaling and kernel diagnostics.

Diagnose an RBF SVM with near-perfect training accuracy, poor validation and nearly all points as support vectors

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Your RBF SVM reaches near-perfect training accuracy but performs poorly on validation data, and almost every training point is a support vector. How would you diagnose and fix it? ```hint Read the kernel values Look at what the RBF kernel returns for two different training points under the current settings, and how that number depends on the scale of the features. ``` ```hint Count the support vectors Ask what a very high support-vector count means when training accuracy is high, and what it means when training accuracy is low. ``` ### Clarifying Questions to Ask - Were the features scaled, and if so, was the scaler fit on the training folds only? - How were `gamma` and `C` chosen: library defaults, hand-set values or a search? - How many samples and features are there? - Is the validation set drawn from the same distribution as the training set? ### What a Strong Answer Covers - What near-perfect training accuracy together with a very high support-vector count says about the kernel width - How feature scaling interacts with the RBF kernel and the `gamma` setting - Concrete diagnostics, such as kernel matrix values, validation curves and the support-vector fraction, plus the other causes to rule out - A fix that tunes `gamma` and `C` jointly, with scaling inside the cross-validation pipeline - What a healthy model looks like after the fix ### Follow-up Questions - Why does lowering `C` alone not fix a model whose `gamma` is far too large? - How does scikit-learn's default `gamma="scale"` relate to feature scaling, and when does it still go wrong? - When would you switch to a linear SVM or another model family instead of tuning the RBF kernel further? - How do training time and prediction latency change after the fix, and why?

Overview: Asks how to diagnose and fix an RBF-kernel SVM that fits the training set almost perfectly, generalizes poorly and keeps nearly every training point as a support vector. Tests understanding of the gamma and C hyperparameters, feature scaling and kernel diagnostics.

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

Your RBF SVM reaches near-perfect training accuracy but performs poorly on validation data, and almost every training point is a support vector. How would you diagnose and fix it?

Clarifying Questions to Ask Guidance

  • Were the features scaled, and if so, was the scaler fit on the training folds only?
  • How were gamma and C chosen: library defaults, hand-set values or a search?
  • How many samples and features are there?
  • Is the validation set drawn from the same distribution as the training set?

What a Strong Answer Covers Guidance

  • What near-perfect training accuracy together with a very high support-vector count says about the kernel width
  • How feature scaling interacts with the RBF kernel and the gamma setting
  • Concrete diagnostics, such as kernel matrix values, validation curves and the support-vector fraction, plus the other causes to rule out
  • A fix that tunes gamma and C jointly, with scaling inside the cross-validation pipeline
  • What a healthy model looks like after the fix

Follow-up Questions Guidance

  • Why does lowering C alone not fix a model whose gamma is far too large?
  • How does scikit-learn's default gamma="scale" relate to feature scaling, and when does it still go wrong?
  • When would you switch to a linear SVM or another model family instead of tuning the RBF kernel further?
  • How do training time and prediction latency change after the fix, and why?