Lesson deck

Decision trees, random forests and gradient boosting flashcards

Reviewing needs JavaScript. You can read every card in the list below.

Loading your cards...

Back to the lesson12 cards in this deck

Read all 12 cards as a list
  1. Front
    Define Gini impurity and Gini gain, and compute the gain for (5+, 5-) split into (4+, 1-) and (1+, 4-).
    Back
    Gini = 1 - sum of p_k squared; gain = parent impurity minus the size-weighted child impurity. Parent 0.5, each child 1 - (0.8^2 + 0.2^2) = 0.32, so gain = 0.5 - 0.32 = 0.18. Entropy gain for the same split is 0.2781 bits.
  2. Front
    What does 'greedy' mean for a decision tree, and what does it miss?
    Back
    Each split is the best one now, with no look-ahead, because finding an optimal tree is NP-complete. On XOR no single split has any gain, yet two levels of splits are perfect, so a tree that only accepts positive gain stops at the root.
  3. Front
    A tree has 100% training accuracy and the data has 15% label noise. What does that tell you?
    Back
    The best possible accuracy on fresh data is about 85%, so a training score above that means the tree memorised wrong labels. Limit max_depth or min_samples_leaf, or prune with cost-complexity pruning, and choose the setting by validation accuracy.
  4. Front
    Write the variance of the average of B predictors with variance sigma^2 and pairwise correlation rho. What does each term teach?
    Back
    rho sigma^2 + (1 - rho) sigma^2 / B. The second term shrinks with more trees. The first is a floor that no number of trees removes, so lowering the correlation (bootstrap samples, random feature subsets) is what moves the floor.
  5. Front
    What does feature subsampling in a random forest buy, and what does it cost?
    Back
    Fewer candidate features per split makes trees less alike (lower rho), which lowers the variance floor. Each tree gets worse (higher variance and bias). In the lesson's six-feature example rho fell from 0.127 to 0.056 but squared bias rose from 0.273 to 0.467, so max_features is tuned.
  6. Front
    What is out-of-bag error, and why are about 36.8% of rows out of bag?
    Back
    A row is missed by one bootstrap sample with probability (1 - 1/n)^n, which tends to 1/e = 0.368. Predicting each row only with the trees that never saw it gives a validation estimate with no held-out set. It is noisy on small data.
  7. Front
    Describe gradient boosting in one pass, naming what each tree is fitted to.
    Back
    Start from a constant. Each round fits a small tree to the negative gradient of the loss at the current predictions (the residual y - F for squared error, y - p for log loss) and adds it scaled by the learning rate: F_m = F_(m-1) + eta h_m.
  8. Front
    How do learning rate, number of rounds and depth interact in boosting?
    Back
    A smaller learning rate takes smaller steps and needs more rounds; given enough rounds it often reaches a lower validation error (in the lesson, rate 0.01 had not caught up with 0.1 by the 800-round cap). Rounds act as regularisation, so choose them by early stopping on validation data, not training loss. Depth sets how many features interact in one tree; shallow trees are the norm.
  9. Front
    Bagging versus boosting: what is each tree trained on, and what is the failure mode of each?
    Back
    Bagging trains deep trees independently on bootstrap samples and averages them; it cuts variance, and more trees only stop helping. Boosting trains shallow trees in sequence on the remaining errors; it builds up the fit, and too many rounds or too large a step overfits.
  10. Front
    Why not trust a forest's default feature importance, and what do you use instead?
    Back
    Impurity importance comes from training statistics and favours features with many distinct values; in the lesson, noise columns took about 75% of it. Use permutation importance on held-out data, and permute correlated features together because they dilute each other.
  11. Front
    How do tree models treat missing values, and why can that beat mean filling?
    Back
    Scikit-learn trees, histogram boosting and XGBoost learn which child missing values go to, so missingness can be a signal. Mean filling puts missing rows among real values and hides it: in the lesson, 0.693 against 0.656 validation accuracy.
  12. Front
    How should a 50,000-level categorical feature be encoded for a tree ensemble?
    Back
    Prefer native categorical support or cross-fitted target encoding; plain one-hot makes 50,000 sparse columns and naive target encoding leaks the label. Scikit-learn's TargetEncoder cross-fits, and fit_transform should be used on training data.