The interview problem

Practice prompt

Explain a linear support-vector classifier's margin, calculate distances for a tiny dataset and show why changing feature units can change the fitted model.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Use binary labels −1 and +1 and the canonical hard-margin constraints y(w·x+b) at least 1. Nonseparable data require slack or another formulation; a hard-margin solution need not exist.

2. Worked approach

The decision surface is w·x+b=0. Signed geometric distance is (w·x+b)/||w||, and maximizing the canonical margin corresponds to minimizing ||w||² subject to correct separation constraints. In a soft-margin objective, C trades norm penalty against constraint violations under the chosen loss convention.

Fit preprocessing only on training data and apply the same transform at serving. A kernel changes the feature geometry; it does not eliminate the need to select hyperparameters and validate on the deployment population. Decision scores are not automatically calibrated probabilities.

3. Calculate the example

For one-dimensional points −2 and +2 with matching labels, w=0.5 and b=0 satisfy both constraints at equality. The distance from either point to the boundary is |0.5×2|/0.5=2. The distance between canonical supporting planes is 2/||w||=4. Multiplying both w and b by two preserves the classifier but changes the functional margins; canonical scaling is what makes the optimization interpretation precise.

4. Failure cases and trade-offs

Calling the raw score a probability overstates its meaning. A feature measured in thousands can dominate distance unless scaling is deliberate. A few mislabeled examples can force a narrow hard margin or make separation impossible.

A linear classifier can be efficient and interpretable in high dimensions. Nonlinear kernels add flexible boundaries but can increase training and serving costs. Larger C penalizes violations more strongly, not universally better generalization.

5. Validate the result

Verify signed distances manually, test invariance of predictions under positive rescaling of w,b, and contrast it with rescaling a feature before refitting. Select C within a leakage-safe validation loop and inspect errors near the boundary.

6. Interview follow-ups and self-review

Why do support vectors determine the boundary? What happens when one label is flipped?

Reward geometric versus functional margin, canonical constraints, scaling discipline and probability caveats.

Sources and related practice

Technical reference: scikit-learn.org — Official SVM formulation reference; geometric example and checks are original.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Connect regularization with probabilistic priors; Feature engineering and missing data.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.