What is Classification? — ML Technical Interview Questions & Answers
Predicting a discrete category label from input features.
What is Classification?
- Simple meaning: Classification predicts a label, not a number. pass/fail, spam/ham, cat/dog. The model may output a probability, then you cut at a threshold.
- Picture: Each student row → “Fail” or “Pass”. You cannot use RMSE as the main score. Use a confusion matrix, then precision/recall.
- Binary = two labels. Multiclass = three or more (A/B/C grades). Different tricks for metrics and for some algorithms.
- Trap: using linear regression for labels. Trap: accuracy when 95% are Pass.
Technical Interview Tip: Labels, not marks. Matrix first, then pick the metric.
Code Examples for What is Classification?
What is 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))What is Classification? — classifiers map features to labels; kNN votes neighbors; logistic uses a sigmoid probability.
How to Explain What is Classification? to an Interviewer
Classification vs regression?
Class vs number
First table to draw?
Confusion matrix