XGBoost

How Five Small Trees Correct a Sales Forecast Step by Step: XGBoost

Gradient boosting for sales forecasting, in which each tree corrects the prediction so far.

XGBoost assembles a forecast from several small decision trees. Each tree learns the correction to the prediction so far. This page works through the method on a sales forecast in fashion retail, with a trained model of five trees and 18 artificial training examples.

XGBoost 3.1 · trained Regression 5 trees · depth ≤ 2 Learning rate 0.4 Fashion retail

Choose the item price, the promotion, the temperature, and the tree that the steps show in detail at the top. Press "Play" and the computation runs by itself, or use the step list to jump to any point.

All computations run in your browser. Teaching example, not a production forecast.

What the Computation View Shows and Where It Ends

The computation view shows a trained XGBoost model for the question of how many T-shirts are sold in one day. Price, promotion, and temperature go in, and a number of units comes out. Split thresholds and leaf weights come from the trained model. It was trained with squared error, exact split search, depth 2, five trees, η = 0.4, and λ = 1.

The model starts from a fixed base value of 40 units. Each tree learns the correction to the prediction so far from gradients and Hessians, chooses splits with a high gain in the regularized objective, and is added to the existing model. The gain values in the XGBoost dump equal twice the gain of the objective written with the factor ½. The leaf weights in the dump are already scaled by η.

The training data consists of 18 artificial examples and is deliberately small. There is no test set. The error reduction is therefore measured on the training set only, and the page reports no test RMSE. It is a teaching example.