Bayesian Random Forest

Machine Learning
Introduced by
Taddy, M. et al.
Year
2015
Type
Bayesian ensemble of decision trees
Family
Machine learning

What does it do?

Bayesian Random Forest extends the classical random forest by placing a prior distribution over tree structures and leaf parameters, then approximating the posterior over the resulting ensemble.

Its predictions come with uncertainty estimates derived from the spread of posterior-weighted trees, which standard random forests do not return by default. It is most relevant when the reliability of a prediction matters as much as the prediction itself.

The intuition behind the method

In a standard random forest, the trees are grown by a fixed algorithmic procedure and the forest returns a single point prediction. A Bayesian random forest instead treats the tree structure and its leaf values as random quantities with a prior. After seeing the data, it updates these beliefs to form a posterior and averages predictions across the posterior-weighted trees. Because the spread of those predictions reflects how much the fitted model could plausibly vary, it can be used to form a credible interval for the fitted function alongside the central estimate. This is useful when sparse data or high-stakes decisions make it important to know where the model is uncertain.

History

Taddy, Chen, Yu and Wyle (2015) presented Bayesian and empirical Bayesian forests at ICML. Their empirical Bayesian variant of tree ensembles was intended to make posterior inference more tractable. Lakshminarayanan, Roy and Teh (2016) proposed Mondrian forests for large-scale regression in settings where uncertainty matters (AISTATS 2016). This is a related but distinct tree ensemble approach with its own construction.

When to use it

Choose a Bayesian random forest when a point prediction is not enough and you need an uncertainty estimate that reflects how much the fit depends on the available data. Examples include clinical decision support or credit risk, where low-confidence predictions should be flagged for review. The method is designed for tabular data with continuous, categorical or mixed features, and it suits problems where nonlinear feature relationships are expected. Prefer a standard random forest when only accurate point predictions are needed and computing budget is limited, since posterior inference adds cost. Avoid it when explicit, interpretable coefficients are required, or when the sample is so small that the prior would drive the posterior; in that case the uncertainty estimates mainly reflect the prior.

Limitations and considerations

  • Posterior inference is considerably more expensive than standard forest training when full MCMC sampling is used.
  • The empirical Bayes approximation may trade some accuracy of the uncertainty estimates for tractability.
  • The model is not summarised by explicit coefficients, so the reasons behind a particular prediction are harder to state than in a linear model.
  • Results depend on the prior over tree structure and leaf parameters; a poorly chosen prior can dominate inference when data are limited.

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

Strengths

  • Provides uncertainty estimates alongside predictions, which standard random forests, as usually implemented, do not return by default.
  • Retains the tree-based handling of nonlinear interactions and mixed feature types, without distributional assumptions on the features.
  • Weighting trees by posterior probability rather than equally, as in standard bagging, makes the prior and likelihood explicit in how the ensemble is formed.
  • Uncertainty estimates can be used to prioritise samples for labelling in active learning, or to flag predictions for review.

Applications

  • Regression on tabular data where predictive intervals should widen in sparsely sampled regions of the feature space.
  • Flagging predictions with wide uncertainty for human review in high-stakes settings such as medical or credit decisions.
  • Active learning, where inputs with high predictive uncertainty are selected for labelling.
  • Screening for unfamiliar inputs, where unusually uncertain predictions may indicate outliers or out-of-distribution cases.

How it works

How it works

1

A prior distribution is placed over tree structures (e.g., depth, split rules) and over leaf-level parameters (e.g., Gaussian distributions on leaf means). This prior encodes beliefs about model complexity before the data are observed, penalising overly deep trees and encouraging regularised leaf estimates.

2

Candidate trees are generated in one of two ways. Full Bayesian approaches use MCMC to explore the space of possible tree topologies. Empirical Bayes approaches, the variant presented by Taddy et al. (2015), approximate this step more cheaply without full MCMC sampling; consult the paper for the exact construction. Each candidate tree represents one plausible explanation of the data.

3

Each candidate tree is evaluated against the observed data using a likelihood function. Trees that fit the data better receive higher posterior weight, and those that fit poorly are down-weighted. The empirical Bayes variant in Taddy et al. (2015) is intended to compute these weights at lower cost than full MCMC; consult the paper for the specific weighting scheme.

4

Predictions are averages over the posterior-weighted trees. For regression, this average is the posterior mean given by the formula above. For classification, the output is an averaged class probability over the posterior-weighted trees, which the formula above does not cover (see the classification entry in the FAQ). The spread of the tree predictions can be used to form a credible interval for the regression function, as described under uncertainty quantification.

Formula
\hat{y} = \mathbb{E}_{T \sim p(T|\mathcal{D})}[f_T(x)]
5

Because each prediction is a posterior average, the spread across plausible trees serves as an uncertainty estimate for the regression function. Regions of input space with little training data tend to produce wider spread, and well-covered regions narrower spread. This spread reflects model (epistemic) uncertainty only. An interval for a new observation must also account for the noise in the outcome itself, which the tree spread does not capture, so such an interval will be too narrow if that noise is ignored. These estimates are approximations, and their quality depends on the sampling or weighting scheme, so they should not be assumed to be perfectly calibrated.

Common pitfalls

  • Reporting the spread across posterior trees as total predictive uncertainty. That spread reflects epistemic (model) uncertainty and omits the outcome noise (aleatoric uncertainty), so intervals for new observations are too narrow if that noise is left out.
  • Using default flat priors without considering the scale of the outcome or the depth of likely trees.
  • Reporting only the posterior mean and discarding the uncertainty estimates that justify using the Bayesian variant in the first place.
  • Trusting uncertainty intervals from small samples where the posterior is prior-dominated.
  • Neglecting computational validation: posterior sampling can silently fail to converge. Rerun with different random seeds and check that predictions and interval widths are stable, and compare held-out error with a standard random forest.

Frequently asked questions

How does a Bayesian random forest differ from a standard random forest?

A standard random forest averages predictions from equally weighted trees and returns a point prediction. A Bayesian random forest weights trees by their posterior probability given the data, and the spread across weighted trees supplies an uncertainty estimate for the fitted function.

Is it much slower than a standard random forest?

Generally yes. Full MCMC-based inference is considerably slower. Empirical Bayes approximations, as in Taddy et al. (2015), are intended to reduce this cost, but they still add overhead relative to standard forest training. The extra cost is the price of obtaining uncertainty estimates.

Do I need to set a prior, and how sensitive are results to it?

Yes, a prior over tree structure and leaf parameters must be specified. When the data are plentiful the likelihood dominates and the prior matters less. When the data are scarce the prior can dominate, so it should reflect genuine domain beliefs about plausible model complexity.

Can I use it for classification as well as regression?

It can be used for both, but the outputs differ by task. For regression, the prediction is the posterior mean given by the formula on this page. For classification, the output is a class probability averaged over the posterior-weighted trees. Treat these probabilities as calibrated only after checking calibration on held-out data, for example with a reliability plot. Do not read them as the posterior probability that a given label is true unless that check has been made.

Which alternatives should I compare it with?

Bayesian decision trees, Gaussian processes and Bayesian gradient boosting, all listed as related methods, are natural comparisons because each can also express uncertainty in some form. Choose by which implementation you can validate, the scale of your data, and how much you need calibrated uncertainty. For large-scale regression where uncertainty matters, the Mondrian forests of Lakshminarayanan et al. (2016) are a relevant reference point.

Related methods

Sources

  1. Taddy, M., Chen, C., Yu, J., & Wyle, M. (2015). Bayesian and Empirical Bayesian Forests. Proceedings of the 32nd International Conference on Machine Learning (ICML 2015), PMLR 37, 967–976.

    Open publication reference
  2. Lakshminarayanan, B., Roy, D. M., & Teh, Y. W. (2016). Mondrian Forests for Large-Scale Regression when Uncertainty Matters. Proceedings of the 19th International Conference on Artificial Intelligence and Statistics (AISTATS 2016), PMLR 51, 1478–1487.

    Open publication reference