Classification algorithms
Understand decision boundaries and probabilistic classifiers.
Choose a classifier based on data structure, calibration and the error costs.
Interview questions
Choose a question to reveal its answer.
01EasyCoreHow does logistic regression predict a class probability?
Answer
How does logistic regression predict a class probability?
Models class probability using a sigmoid of a linear score in binary classification.
Estimate whether a transaction is fraudulent with a linear decision boundary.
02EasyCoreHow does a decision tree choose a split?
Answer
How does a decision tree choose a split?
Recursively splits feature space using criteria such as impurity reduction.
Build interpretable conditional rules for loan eligibility.
03EasyCoreWhy can a random forest generalize better than a single tree?
Answer
Why can a random forest generalize better than a single tree?
Averages or votes across randomized trees, typically trained on bootstrap samples.
Reduce variance relative to an individual unstable tree.
04MediumHigh priorityHow does gradient boosting improve a model?
Answer
How does gradient boosting improve a model?
Sequentially adds weak learners to improve a loss objective using gradient information.
Fit trees to progressively correct residual errors.
05MediumHigh priorityWhat is the maximum-margin principle in SVM?
Answer
What is the maximum-margin principle in SVM?
Finds a maximum-margin decision boundary with optional kernels and soft-margin regularization.
Separate two groups while prioritizing margin size.
06MediumHow does KNN classify an unseen observation?
Answer
How does KNN classify an unseen observation?
Predicts using labels of nearby training examples under a chosen distance.
Classify a new item based on its closest labeled items.
07MediumWhat assumption does Naive Bayes make?
Answer
What assumption does Naive Bayes make?
Uses Bayes rule with conditional independence assumptions among features given the class.
Build a simple text classifier from word counts.
08MediumVisualWhy is the sigmoid function used for binary classification?
Answer
Why is the sigmoid function used for binary classification?
Maps a real-valued score to a number between zero and one.
Convert binary logistic regression logits to probabilities.
from math import exp
z = 1.5
p = 1/(1+exp(-z))
print(p, int(p >= 0.5))Separate estimated probability from the decision threshold.
09HardWhat happens when you lower a classification threshold?
Answer
What happens when you lower a classification threshold?
Probability or score cutoff used to assign a predicted label.
Lower a fraud cutoff to catch more potential fraud cases.
10HardHow can class weighting address imbalanced training data?
Answer
How can class weighting address imbalanced training data?
Changes the contribution of classes to training loss.
Penalize missed minority-class examples more strongly.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. A binary classifier returns a probability of 0.7 and the threshold is 0.8. Which class is predicted?
2. What typically reduces the variance of a decision tree?
3. Which classifier uses conditional independence given the class?
Clustering and dimensionality reduction
Continue to the next set of interview questions.