Classical Machine LearningIntermediate20 min read5 questions

Decision Trees, Random Forests & Gradient Boosting

Gradient boosting still wins most tabular problems in production. Know how it works internally, why it beats random forests, and how to explain its predictions.

Covers: Tree splitting criteria, bagging vs boosting, XGBoost/LightGBM internals, feature importance, SHAP, hyperparameter tuning

If a company has tabular data — and almost every company does — gradient boosting is probably running in production somewhere. Interviewers know this, so tree questions get asked far more often than the deep-learning questions candidates over-prepare for.

Filter
0/5 mastered
Foundationaldecision-treessplittinginformation-gainAsked at Amazon, Capital One

30-second answer

It greedily evaluates every feature and threshold and picks the split that maximises the reduction in an impurity measure, weighted by child sizes. Classification uses Gini (1 − Σp²) or entropy (−Σp log p); regression uses variance/MSE reduction. Gini and entropy agree on the chosen split about 98% of the time, so Gini is preferred purely because it avoids a logarithm.

Intermediateensemblesrandom-forestboostingAsked at Amazon, Uber

30-second answer

Bagging trains many deep, low-bias, high-variance trees on bootstrap samples in parallel and averages them — averaging independent errors reduces variance without adding bias, so more trees only ever converges. Boosting trains shallow, high-bias trees sequentially, each fitting the previous ensemble's residuals — this reduces bias but each tree also fits some noise, so past a point more trees increases variance and test error rises.

AdvancedxgboostlightgbmcatboostAsked at Kaggle-heavy teams, Instacart

30-second answer

XGBoost uses second-order gradients with explicit regularisation and grows trees level-wise. LightGBM grows leaf-wise (best-first), uses histogram binning plus GOSS sampling and exclusive feature bundling, making it much faster on wide/large data but more prone to overfitting on small data. CatBoost uses ordered boosting and ordered target statistics to eliminate the prediction-shift bias from categorical encoding, and is the strongest default when you have many categorical features.

Advancedinterpretabilityshapfeature-importanceAsked at Capital One, Zillow

30-second answer

Default impurity-based importance is biased toward high-cardinality and continuous features, is computed on training data so it rewards overfitting, and splits credit arbitrarily among correlated features. Use permutation importance on a held-out set for a global, model-agnostic view, and SHAP values when you need per-prediction attributions with consistency guarantees.

Advancedhyperparameter-tuningbayesian-optimizationgbdtAsked at Kaggle-grandmaster teams, Instacart

30-second answer

Fix the learning rate low and let early stopping choose the tree count, then tune in order of impact: tree complexity (max_depth/num_leaves, min_child_weight), then sampling (subsample, colsample), then regularisation (lambda, alpha). Use Bayesian optimisation or Optuna's TPE rather than grid search, add a pruner to kill bad trials early, and always tune against the same CV scheme you will report.

Showing 5 of 5 questions for trees-ensembles-and-boosting-interview.

Check your understanding

5 questions · no sign-up, nothing stored

0/5 answered
Question 1

1.Gini impurity versus entropy as a splitting criterion:

Question 2

2.Why can adding more trees hurt a gradient boosted model but not a random forest?

Question 3

3.In LightGBM, leaving `max_depth = -1` with `num_leaves = 255` on a 5,000-row dataset will most likely:

Question 4

4.A random row-id column ranks first in `feature_importances_`. This happens because:

Question 5

5.Best practice for tuning `learning_rate` and `n_estimators` in boosting:

Hands-on challenge

Build it — this is what you talk about in a deep-dive round.

Beat a tuned GBM baseline the honest way

Take any tabular dataset and build a reproducible pipeline that improves on a default LightGBM without fooling yourself.

Requirements

  • A leak-free CV scheme appropriate to the data (grouped and/or time-based), used identically for every experiment.
  • Baseline: LightGBM with defaults + early stopping. Record the CV mean and standard deviation.
  • Optuna search with a pruner over the priority-ordered space; log every trial.
  • Compare impurity, permutation and SHAP importances and write up where they disagree and why.

Stretch goals

  • Add a 5-seed average of the best configuration and quantify the gain versus more search trials.
  • Stack LightGBM + CatBoost + a regularised linear model and measure whether stacking beats the best single model by more than one standard error.