Machine Learning Fundamentals interview question · Most asked
Compare decision trees, random forests and gradient boosting.
Comparison Asked in Machine Learning Engineer interviews
Summary
A decision tree splits data with if/else rules; it's interpretable but overfits easily. A random forest averages many deep trees trained on random samples and feature subsets, which reduces variance. Gradient boosting (XGBoost, LightGBM, CatBoost) builds shallow trees one after another, each fixing the previous errors, and usually gives the best accuracy on tabular data with more tuning.
Longer Answer
| Decision tree | Random forest | Gradient boosting | |
|---|---|---|---|
| Training | one tree | parallel, independent trees | sequential trees |
| Main risk | overfitting | larger, slower models | overfitting without early stopping |
| Tuning | depth, min samples | number of trees, max features | learning rate, depth, trees, regularisation |
| Strength | explainable | robust defaults | top accuracy on tabular data |
Tree models need no feature scaling, handle non-linear relations and mixed types, and give feature importances (prefer permutation importance or SHAP, as split-based importance favours high-cardinality features).
Key Points
- Trees: interpretable, overfit.
- Forests: bagging lowers variance.
- Boosting: sequential, strongest on tabular.
- No scaling needed; use SHAP or permutation importance.
Explanation
What interviewers look for
Understanding bagging vs boosting and why boosting dominates tabular problems.
More Machine Learning Fundamentals questions
- Your model scored well offline but performs badly in production. What do you check?
- What is the difference between supervised, unsupervised and reinforcement learning?
- Explain the bias-variance trade-off.
- What is data leakage, and how do you detect it?
- Which metrics would you use for a classification model, and when is accuracy misleading?
- What is overfitting, and how do you prevent it?
- How do you split data for training, validation and testing, and what is cross-validation?
- Design a system that serves predictions from a trained model to a web application.