Skip to content

Random forest

A random forest combines randomised decision trees. Understand per-split feature subsampling, regression averaging and the limits of financial validation.

A random forest combines many decision trees trained with deliberate randomness. In the standard bagged-tree construction, each tree receives a resampled training set and considers a random subset of features at each split. Regression predictions are averaged; classification needs a specified aggregation rule. For a quant using market features to predict returns, the attraction is a flexible model whose result depends less on the particular branches of one fitted tree.

Why restrict what a tree can see?

Bagging already changes the training rows through bootstrap sampling with replacement. Yet if one feature dominates the split criterion, many bagged trees can choose it near the root and make similar predictions.
A random forest adds feature subsampling. At each node it draws candidate features, then searches for a good split among those candidates. It does not simply choose a random split threshold, nor does it normally choose one permanent feature subset for the whole tree. Fresh candidates are drawn at the next split.

Suppose the available features are momentum, value, volatility and liquidity, and the illustrative candidate count is two. A particular node might consider only value and volatility. Even if momentum would have produced the best split among all four features, that node must choose from its permitted pair. Another node can consider momentum again.

The purpose is to reduce similarity between trees while retaining useful individual predictions. That is a trade-off: restricting candidates too severely can weaken the trees. The candidate count, tree depth and leaf-size rules belong in model selection; no single setting is best for every target. Holding the rest of the bagged-tree construction fixed, allowing every feature at each split removes this particular distinction from bagging. See the ISLP treatment of random forests, §8.2.2.

One forecast, several trees

Let xx denote the feature vector for one asset at one decision time, and let f^b(x)\hat f_b(x) be tree bb's predicted next-day simple return. For an unweighted regression forest of BB trees,

f^RF(x)=1B∑b=1Bf^b(x).\hat f_{\mathrm{RF}}(x)=\frac{1}{B}\sum_{b=1}^{B}\hat f_b(x).
Take three stipulated tree outputs of 33, 55 and 77 basis points, all for that same target and horizon. The forest prediction is
3+5+73=5 bp.\frac{3+5+7}{3}=5\text{ bp}.
Training illustration with four row IDs and three resamples; each pictured split considers two of four features. Supplied next-day return outputs 3, 5 and 7 basis points for the same asset and decision time average 5 basis points.
Training illustration with four row IDs and three resamples; each pictured split considers two of four features. Supplied next-day return outputs 3, 5 and 7 basis points for the same asset and decision time average 5 basis points.
Original stipulated illustration. Resampled rows, candidate sets and outputs illustrate separate steps; no model was fitted and the displayed outputs were not derived from the displayed samples.

The averaging is straightforward. The statistical question is whether those trained trees contain useful information about an unseen outcome. Different random draws during fitting do not make their errors independent: the trees share historical data, labels and market structure. Nor are these three outputs independent realised returns. The mean establishes neither predictive skill nor a tradable edge.

For a deeper treatment of feature subsampling and a seeded synthetic comparison, read Bagging and Random Forests (membership; public preview).

A class vote is a different object

For classification, labels are categories. Averaging arbitrary codes for several classes does not produce a useful class prediction. In a binary 0/1 voting scheme, the mean code is the fraction of positive votes; it is not automatically a calibrated probability. Breiman's original definition gives each tree one class vote and chooses the most popular class. By contrast, scikit-learn's RandomForestClassifier selects the class with the highest mean estimated class probability across its trees. Its predict_proba averages the tree probability estimates. These are distinct conventions; check the implementation before interpreting its output. A vote share alone is not evidence of a calibrated event probability. See Breiman's definition and the official classifier prediction documentation.

A forest still needs a financial test

An out-of-bag prediction uses trees whose bootstrap samples omitted the observation being assessed. That omission does not ensure that nearby or overlapping financial outcomes were absent, or that the training information was available at the historical decision time. Randomisation does not repair look-ahead bias.
Keep feature construction, label availability, tuning and refitting within the declared information schedule. Assess later observations under that schedule and compare against a simpler baseline; adding trees cannot create missing information. The time-series validation guidance explains the dependence problem. Time-Ordered Train, Validation and Test Design (membership; public preview) develops the financial workflow, including completed labels and fitting the whole pipeline inside each training window.

Sources

Last updated
  • machine learning
  • decision trees
  • ensembles
  • feature subsampling
  • financial validation
← Back to the glossaryBack to top ↑