Random forest

How Five Decision Trees Jointly Assess a Stock Shortage: Random Forest

A random forest of five decision trees estimates the risk of a stock shortage, worked through step by step.

A retailer wants to know before the next delivery whether an item is likely to sell out. A random forest of five decision trees classifies the case from stock, daily sales, and lead time as "shortage" or "no shortage." This page works through the path from the bootstrap sample to soft voting.

Random forest · trained Classification 5 decision trees Bootstrap · Gini Fashion retail

Choose stock, daily sales, and lead time at the top, along with the tree you want to see in detail. 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 View Shows and Where It Ends

The view classifies an item from stock, daily sales, and lead time as "shortage" or "no shortage." It shows the bootstrap sample of one tree, its splits with the Gini impurity, the path of the item down to the leaf, and the averaging of the five trees.

Each tree gets its own sample drawn with replacement. At every split the random forest generally considers a random subset of the features, and here scikit-learn uses max_features=2 out of three features with a maximum depth of 3. A split is meant to minimize the weighted impurity of the children. At the end, the RandomForestClassifier of scikit-learn averages the class probabilities of all trees.

The data is synthetic. It consists of 27 cases with a label from a simplified stock rule, with no real company data and no independent test. This page computes no out-of-bag quality score. The export does not store which unchosen features were examined at a split, and they are not invented. The model probability is not calibrated. A production solution would need time-separated validation, calibration, the cost of errors, and real data.