Binary vs Multiclass Classification — ML Technical Interview Questions & Answers
Two-class problems vs three-or-more class problems.
Binary vs Multiclass Classification
- Simple meaning: Binary = two classes (spam / not). Multiclass = three or more (red / yellow / green). Multilabel is different again — one email can be both “work” and “urgent”.
- Picture: Pass/fail is binary. Grade A/B/C/D/F is multiclass. Don’t use a metric recipe from binary without checking (macro vs micro F1).
- Some models are naturally multiclass (trees, softmax nets). Some are binary-first (classic SVM) and use one-vs-rest.
- Trap: treating grades as a number 1–5 with linear regression and calling it classification. Trap: one-hot y by mistake in a model that wants 0,1,2.
Technical Interview Tip: Two classes vs many. Multilabel is ‘several tags at once’.
Code Examples for Binary vs Multiclass Classification
Binary vs Multiclass Classification — 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))Binary vs Multiclass Classification — classifiers map features to labels; kNN votes neighbors; logistic uses a sigmoid probability.
How to Explain Binary vs Multiclass Classification to an Interviewer
Binary example?
Spam vs ham Pass vs fail
Multiclass example?
Grades A–F Digit 0–9