Support Vector Machine (SVM) — ML Technical Interview Questions & Answers

Finding the maximum-margin boundary between classes.

Support Vector Machine (SVM)

  • Simple meaning: SVM draws the widest possible street between two classes. The edge students (support vectors) hold up the boundary. New point: which side of the street?
  • Picture: Pass dots and fail dots on paper. The line in the middle with the fattest empty margin. Kernel (RBF) bends the street when a straight line is not enough.
  • Scale features first. sklearn: SVC(kernel='linear' or 'rbf'). Slow and picky on huge messy sheets — fine for medium, clear-margin problems.
  • Trap: no scaling. Trap: a huge C that lets almost no mistakes on train (overfit) without saying it.

Technical Interview Tip: Widest gap between classes. Scale. Support vectors matter.

Code Examples for Support Vector Machine (SVM)

Support Vector Machine (SVM) — working example

def majority_vote(labels):
    return max(set(labels), key=labels.count)

neighbors = [1, 1, 0, 1, 0]
print(majority_vote(neighbors))  # kNN-style vote

# Logistic idea: score → probability via sigmoid
def sigmoid(z):
    return 1 / (1 + 2.718281828 ** (-z))
print(round(sigmoid(0.0), 3), round(sigmoid(2.0), 3))

Support Vector Machine (SVM) — classifiers map features to labels; kNN votes neighbors; logistic uses a sigmoid probability.

How to Explain Support Vector Machine (SVM) to an Interviewer

What does SVM maximise?

The margin between classes

What are support vectors?

Points closest to the boundary