A gradient-boosted tree model was trained on months 1–36 of demand, using month_index as a feature. Its forecast for months 37–48 is the flat line in the plot. Why does it look like this, and what is the fix?
Show the answer and explanation
Correct answer: B, Each tree is piecewise constant in month_index, so every month after 36 lands in the same leaf as month 36; model the trend separately, e.g. by detrending.
Explanation Decision Trees
A tree partitions the feature space into regions and predicts a constant in each leaf (an average of training targets or, in boosting, of residuals). Every split threshold on month_index lies inside the training range, so in each tree months 37–48 fall into the same leaf as month 36, and the ensemble repeats its month-36 fit (about 204, close to the average of the last few training months). Tree models therefore cannot extrapolate a trend; a random forest cannot even leave the range of the training targets.
Common fixes:
- Detrend or difference: predict the change yₜ − yₜ₋₁ or the ratio to a trend, then add the trend back.
- Hybrid model: fit a linear or time-series model for trend and seasonality, and let the trees model the residuals using lags, promotions and calendar features.
- Use models with linear leaves (e.g. LightGBM
linear_tree), or classical/neural forecasting models where trend extrapolation matters. - Replace the raw time index with lag and rolling features of the detrended or differenced series; lags of the raw level leave the training range just as the index does.
Why the distractors fail: more depth or more trees only add finer steps inside the training range. The learning rate controls step size per round, not the range of predictions. Trees split on thresholds and depend only on the order of feature values, so scaling month_index moves the thresholds but leaves every prediction unchanged.
Interview tip: this is a frequent senior-level trap in pricing, demand and revenue forecasting. Say explicitly: "tree ensembles interpolate but do not extrapolate, so I handle the trend outside the trees and validate with a time-based split."