yoklainterview sim

ML Engineer Cml Gradient Boosting Mechanics Interview Questions

75 verified ML Engineer Cml Gradient Boosting Mechanics interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Cml Gradient Boosting MechanicsDifficulty 1
In gradient boosting, what is each newly added tree fit to predict?
  • aThe original target again, so that every tree in the ensemble becomes an independent estimate of it.
  • bA bootstrap resample of the target, drawn separately for each tree in the boosting sequence.
  • cThe average of the predictions that all previously fitted trees produced for that same row.
  • dWhatever the current ensemble still gets wrong, expressed as the negative gradient of the loss.
Explanation:Boosting is additive: the prediction is an initial estimate plus the shrunken output of each tree in turn, and every tree is fit to the negative gradient of the loss at the current prediction. Fitting the raw target independently, or bootstrapping it per tree, describes bagging-style ensembles such as random forests. Averaging earlier predictions would add no new information at all.
Cml Gradient Boosting MechanicsDifficulty 2
scikit-learn 1.6:

import numpy as np
from sklearn.ensemble import GradientBoostingRegressor

X = np.array([[1.], [2.], [3.], [4.]])
y = np.array([2., 4., 6., 20.])
g = GradientBoostingRegressor(n_estimators=1, learning_rate=0.1,
                              max_depth=1, loss='squared_error').fit(X, y)
print(g.predict([[4.]]))


The single stump splits between x=3 and x=4. What is printed?
  • a[8.0]
  • b[9.2]
  • c[20.0]
  • d[6.8]
Explanation:The initial estimate is the mean of y, 8.0, so the residuals are [-6, -4, -2, 12]. The stump isolates x=4 in a leaf whose value is 12, and the learning rate shrinks that step: 8.0 + 0.1 * 12 = 9.2. Staying at 8.0 would mean the tree contributed nothing, reaching 20.0 would need a learning rate of 1.0, and 6.8 comes from subtracting the leaf value instead of adding it.
Cml Gradient Boosting MechanicsDifficulty 3
A team fits GradientBoostingRegressor(loss='quantile', alpha=0.9) in scikit-learn 1.6 on a target with a long right tail. What does predict estimate?
  • aThe mean of the conditional target distribution, with alpha shrinking each tree's contribution by a further factor of 0.9.
  • bThe mean of the conditional target distribution, with alpha widening a prediction interval reported separately.
  • cThe 90th percentile of the conditional target distribution, so about nine rows in ten fall below the prediction.
  • dThe 10th percentile of the conditional target distribution, since alpha names the tail mass the estimate leaves above itself.
Explanation:The quantile loss weights positive and negative errors asymmetrically — under-prediction is charged alpha and over-prediction 1 - alpha — so the constant minimising it is the alpha-quantile and the boosted fit tracks that quantile conditionally. On a fitted model roughly alpha of the training rows sit at or below the prediction. Shrinkage is set by learning_rate, and nothing here estimates the mean or reverses the tail.
Cml Gradient Boosting MechanicsDifficulty 2
A binary GradientBoostingClassifier is fit on data where 20% of the labels are positive. What raw score does the model start from before any tree contributes?
  • a0.20, the positive rate used directly on the probability scale.
  • b0.0, because the raw score scale is always centred at the start of boosting.
  • clog(0.2), about -1.609, the natural logarithm of the positive rate.
  • dlog(0.2 / 0.8), about -1.386, the log-odds of the training prior.
Explanation:Boosting for log loss operates on the raw logit scale, and the constant that minimises log loss there is the log-odds of the class prior, log(p / (1 - p)). With p = 0.2 that is about -1.386, which maps back through the logistic function to a probability of 0.2. Using the rate itself, or its plain logarithm, mixes the probability scale up with the raw score scale.
Cml Gradient Boosting MechanicsDifficulty 2
A team lowers learning_rate from 0.1 to 0.01 in GradientBoostingClassifier and leaves n_estimators at 100. Both training and validation loss get clearly worse. What is going on?
  • aEach tree now contributes a tenth as much, so 100 rounds no longer cover the signal and the model underfits.
  • bA smaller learning rate makes each tree deeper, and the deeper trees memorised training noise.
  • cBelow 0.05 the learning rate switches the objective to absolute error, which fits a centred target poorly.
  • dShrinkage that small disables the initial estimate, so the ensemble has to start from a raw score of zero.
Explanation:The learning rate multiplies every tree's output before it is added, so total progress after n rounds scales roughly with rate times n. Cutting the rate tenfold without raising the round count leaves the ensemble far short of the fit it had, and worse loss on both splits is the signature of underfitting rather than overfitting. The learning rate does not touch tree depth, the objective, or the initial estimate.
Cml Gradient Boosting MechanicsDifficulty 1
The learning_rate parameter of scikit-learn's gradient boosting (called eta in XGBoost) multiplies which quantity?
  • aThe output of each new tree, before that output is added to the running prediction.
  • bThe depth budget granted to each individual tree as boosting proceeds through its rounds.
  • cThe gradient used to score candidate splits, leaving the leaf values untouched.
  • dThe fraction of training rows drawn at random for each boosting round of the fit.
Explanation:Shrinkage scales the contribution of every fitted tree, so the ensemble takes many small steps instead of a few large ones; XGBoost describes eta as shrinking the new weights to make boosting more conservative. Depth is set separately by max_depth or max_leaf_nodes and row sampling by subsample, and the shrinkage lands on the leaf values themselves rather than only on the split search.

Test yourself against the 1050-question ML Engineer bank.

Start interview