When to choose logistic regression over SVMs, decision trees, or random forests: advantages and disadvantages
Role: Data Scientist
Category: Machine Learning
Difficulty: medium
Interview Round: Other
When would you choose logistic regression over other classification algorithms such as support vector machines (SVMs), decision trees, or random forests? What are its main advantages and disadvantages?
```hint Start from the model form
Write down what logistic regression fits and what shape of decision boundary that gives in the original features.
```
```hint Compare more than accuracy
Look at what each model outputs, how it trains, how it scales, and how easy it is to explain to someone who has to trust it.
```
### What a Strong Answer Covers
- The model form and the kind of decision boundary it implies
- The advantages of logistic regression: interpretable coefficients, probability outputs, convex training, and regularization
- Its limitations, including non-linear data, correlated features, and perfect separation
- How it compares with SVMs, single decision trees, and tree ensembles
- Concrete situations where it is the right first choice and where it is not
### Follow-up Questions
- How would you check whether the predicted probabilities are well calibrated, and what would you do if they are not?
- What happens to the coefficients under perfect separation, and how would you fix it?
- How would you let logistic regression capture an interaction between two features?
- When would you prefer L1 over L2 regularization for logistic regression?
Overview: Asks when logistic regression is a better choice than SVMs, decision trees, or random forests for a classification problem, and what its strengths and weaknesses are. Tests understanding of the linear log-odds model, interpretability, probability outputs, and how the model behaves on non-linear data.