Decision Boundaries — ML Technical Interview Questions & Answers

The surface that separates predicted classes.

Decision Boundaries

  • Simple meaning: The decision boundary is the line/curve/surface where the model changes its mind (pass vs fail). On one side predict A, on the other B.
  • Picture: Hours on x, attendance on y. A linear model draws a straight cut. A tree draws axis-aligned rectangles. RBF-SVM can draw a wiggly loop.
  • Plotting it (two features) is the best way to see overfit — a boundary that snakes through every training dot.
  • Trap: drawing a boundary for a model that outputs a number (regression has a surface, not a class cut). Trap: 20 features and still talking as if you can see the boundary in 2D.

Technical Interview Tip: Where the class flips. Straight, boxes, or wiggles — depends on the model.

Code Examples for Decision Boundaries

Decision Boundaries — working example

# ROC idea: vary threshold on scores
y_true = [0, 0, 1, 1]
scores = [0.1, 0.4, 0.35, 0.8]

def tpr_fpr(threshold):
    pred = [1 if s >= threshold else 0 for s in scores]
    tp = sum(t == 1 and p == 1 for t, p in zip(y_true, pred))
    fp = sum(t == 0 and p == 1 for t, p in zip(y_true, pred))
    fn = sum(t == 1 and p == 0 for t, p in zip(y_true, pred))
    tn = sum(t == 0 and p == 0 for t, p in zip(y_true, pred))
    tpr = tp / (tp + fn)
    fpr = fp / (fp + tn)
    return tpr, fpr

for thr in (0.3, 0.5, 0.75):
    print(thr, tpr_fpr(thr))
# Boosting: train trees sequentially on residuals / hard examples

Decision Boundaries — rOC plots TPR vs FPR across thresholds; AUC summarizes ranking quality. Boosting builds strong learners from weak ones.

How to Explain Decision Boundaries to an Interviewer

What is a decision boundary?

Where the predicted class changes

Tree boundary shape?

Axis-aligned splits Rectangles