Online Random Forest

Machine Learning
Introduced by
Saffari, A. et al.
Year
2009
Type
Incremental ensemble (streaming decision trees)
Family
Machine learning

What does it do?

Online Random Forest (ORF) extends the Random Forest ensemble to streaming settings.

Each tree is updated incrementally as observations arrive, so the method does not need a stored training set. Adaptive Random Forest (ARF), a specific algorithm within this family introduced for evolving data streams, is designed to adapt when the data distribution changes. Here, Online Random Forest denotes the general family, and ARF denotes the drift-adaptive variant introduced by Gomes et al. (2017).

The intuition behind the method

A batch Random Forest needs the whole dataset before its trees are grown. Online Random Forest instead passes each incoming observation to every tree, and each tree draws a Poisson(1) count that determines how many times it uses that observation for training. This approximates bootstrap sampling without storing the data. Trees grow incrementally, with split decisions based on per-leaf statistics and criteria such as the Hoeffding bound. An optional drift detector, such as ADWIN, monitors each tree's error and replaces trees that have become unreliable. Predictions are obtained by voting across the trees, so the ensemble still averages over diverse trees.

History

Saffari et al. (2009) introduced On-line Random Forests at the IEEE workshop on on-line learning for computer vision. Gomes et al. (2017) introduced Adaptive Random Forests for evolving data-stream classification.

When to use it

Choose Online Random Forest when observations arrive one at a time, or in batches too large to hold in memory, and predictions are needed before the full dataset exists. It suits settings where the input distribution may change, such as financial, sensor or user-behaviour streams, provided drift detection is included. Do not use it when the full dataset fits in memory and offline retraining is affordable; a standard Random Forest trained on all the data is usually simpler to validate. Also avoid it when stable, reproducible feature-importance rankings are the main output, since importance estimates from online forests may vary more across runs or stream segments than batch estimates. Validate their stability empirically before relying on rankings.

Limitations and considerations

  • Early splits made on sparse data can be sub-optimal and are hard to revise once the leaf has been expanded.
  • Feature-importance estimates may vary more across runs or stream segments than those from a batch Random Forest.
  • Hyperparameters such as the number of trees and drift-detection sensitivity interact with the stream, so tuning them is harder than in batch training.
  • Evaluation needs stream-based protocols such as prequential (test-then-train) evaluation, which differ from standard cross-validation.
  • Split decisions based on the Hoeffding bound assume that observations are independent and drawn from a stable distribution. Between drifts this is the working assumption, and a change in the distribution can make earlier split decisions outdated.
  • Poisson(1) weighting approximates bootstrap sampling and assumes observations arrive one at a time in their natural order. The approximation is not exact.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each tree is updated one observation at a time, so the raw stream does not need to be stored or replayed; memory is held in per-leaf statistics instead.
  • Pairing the forest with a drift detector such as ADWIN allows individual trees to be replaced when their error rises, rather than retraining the whole ensemble.
  • Voting across trees that see different Poisson-weighted samples keeps the variance-reduction benefit of ensemble averaging in an online setting.
  • Predictions can be produced early in the stream, and the forest improves as more observations are processed.

Applications

  • Real-time fraud and intrusion detection on network or transaction streams.
  • Predictive maintenance from sensor streams where distributions shift with equipment ageing.
  • Click-through rate prediction in advertising where user behaviour evolves daily.
  • Medical monitoring where patient state changes continuously over time.
  • Environmental and climate sensing with non-stationary seasonal patterns.

How it works

How it works

1

A set of T trees (or Hoeffding trees) is initialised. Each tree keeps per-leaf sufficient statistics, such as class counts or, for regression, sum-of-squares terms, instead of raw observations. Each tree's size still grows with the number of leaves it creates, so limits on growth matter in practice.

2

For each arriving observation, each tree independently draws k from a Poisson(1) distribution and treats the observation as k copies of itself. When k = 0 the tree skips the observation, so it acts as an out-of-bag sample for that tree.

Formula
k \sim \text{Poisson}(\lambda),\; \lambda=1
3

Each tree updates the statistics at its active leaf. A leaf is split when a statistical criterion, such as the Hoeffding bound, indicates that the best split is unlikely to change with more data. The leaf then becomes an internal node with new leaves.

4

An optional detector such as ADWIN monitors each tree's prediction error as the stream is processed. When the detector signals a significant increase in error, the affected tree is reset or replaced by a freshly initialised tree.

5

At any point, the active trees vote: majority vote for classification or mean prediction for regression. Trees that have processed very few examples may be down-weighted or excluded until they have seen enough data to give reliable votes.

Formula
\hat{y} = \text{mode/mean of active trees}

Common pitfalls

  • Using standard k-fold cross-validation, which assumes independent observations and ignores temporal order; prequential evaluation is the appropriate alternative.
  • Omitting drift detection when the data distribution is expected to change, so stale trees remain in the vote.
  • Comparing the online forest with a batch Random Forest trained on the full historical data, which has access to information the online model did not have at each step.
  • Starting with too few trees, or judging the forest before its trees have seen enough data to form reliable splits.
  • Treating Poisson-weighted bagging as an exact bootstrap: a Poisson(1) count approximates sampling with replacement, but the resulting tree samples do not reproduce batch bootstrap statistics exactly.

Frequently asked questions

How does Online Random Forest differ from standard Random Forest?

Standard Random Forest trains all trees on the full dataset using bootstrap sampling. Online Random Forest replaces batch bootstrap sampling with Poisson-weighted online bagging, updates splits incrementally as observations arrive, and can optionally detect and adapt to concept drift, all without storing past data.

What is the Poisson weighting trick?

Each incoming example is shown to each tree k times, where k is drawn from Poisson(1). Because the expected value of k is 1, and k = 0 with probability ~37%, this statistically approximates the bootstrap process (sampling with replacement) without needing the full dataset in memory.

How should I evaluate an online random forest?

Use the prequential (test-then-train) protocol: for each incoming observation, first predict with the current model, record the error, then update the model. This gives an estimate of predictive performance that follows temporal order and avoids data leakage.

When should I add drift detection?

Add it whenever the data-generating process may change over time, such as user preferences, financial markets or mechanical systems subject to wear. Without it, stale trees can remain in the vote and reduce accuracy. ADWIN is one example of a detector used for this purpose.

Is Adaptive Random Forest the same thing?

ARF is a specific algorithm within the online forest family, introduced by Gomes et al. (2017) for evolving data-stream classification, and it is the variant documented in the Gomes et al. (2017) reference on this page. The term 'Online Random Forest' is used more generally, so the two are not interchangeable in every context.

Related methods

Sources

  1. Saffari, A., Leistner, C., Santner, J., Godec, M., & Bischof, H. (2009). On-line random forests. In Proceedings of the 3rd IEEE International Workshop on On-Line Learning for Computer Vision (OLCV 2009), pp. 1–8. IEEE.

    Open publication reference
  2. Gomes, H. M., Bifet, A., Read, J., Barddal, J. P., Enembreck, F., Pfharinger, B., Holmes, G., & Abdessalem, T. (2017). Adaptive random forests for evolving data stream classification. Machine Learning, 106(9), 1469–1495.

    Open DOI reference