ATLAS NOVA My AtlasVelocer ↗

Method · Machine learning

Random forest

Machine learning method

A random forest is a prediction method built from many decision trees at once.

A single decision tree asks a series of yes-or-no questions about a case's features and follows the answers down to a leaf that gives a prediction. That is easy to read but fragile: a small change in the training data can reshape the tree and change its answers. A random forest avoids this by growing a large collection of trees, each on a slightly different version of the data, and letting them vote. For a classification problem the forest assigns the class chosen by most trees; for a numeric outcome it averages their predictions.

Key facts
0.8084Random forest's top accuracy predicting diabetes from Luzhou hospital records⁠[1]
69%Share of 243 datasets where random forest beat logistic regression⁠[2]
202,919Genotypes integrated by Darst et al. 2018 to test feature elimination⁠[3]

Overview

Random forest

A concrete case shows what the method does. In a study of diabetes, hospital physical-examination records from Luzhou, China, with 14 attributes per person, were used to train three classifiers: a single decision tree, a random forest, and a neural network. The random forest reached the highest accuracy of the three, 0.8084, when all attributes were used, and it also gave the best results when blood glucose, LDL and HDL were removed from the inputs.⁠[1] The example illustrates the typical setting: many candidate predictors, some informative and many not, and a need for a prediction that holds up on new cases.

Four small decision-tree flowcharts arranged in a 2x2 grid, each with yes/no branches leading to boxes labelled Cancer or Non-cancer, with some leaf boxes highlighted in green or red.
Four small decision-tree flowcharts arranged in a 2x2 grid, each with yes/no branches leading to boxes labelled Cancer or Non-cancer, with some leaf boxes highlighted in green or red. View full-size image.Random Forest Diagram Extra Wide by CollaborativeGeneticist. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The reason averaging helps is statistical. Individual trees are high-variance learners: their predictions jump around from sample to sample. If the trees were all alike, averaging them would change nothing. The forest deliberately makes them differ, by giving each tree a different random sample of the data and a different random subset of variables to consider at each split. The result is a set of trees that are individually imperfect but whose errors partly cancel when combined, so the ensemble can be both accurate and stable. This is the logic of ensemble learning, in which several models are combined into one prediction.

Random forests matter because they work on problems where the number of variables is far larger than the number of cases, and because they report which variables drove the predictions. Their standing is not uniform, however. A benchmark across 243 real datasets found the random forest more accurate than logistic regression in roughly 69% of them, with a mean accuracy advantage of 0.029.⁠[2] Against support vector machines on 22 microarray cancer datasets, the ordering reversed: the support vector machine had the lower error, both with and without gene selection.⁠[4] The variable importance scores that make the method interpretable are also known to be biased in favor of variables with many categories or a high number of split points.⁠[5][6]

A random forest trades the transparency of one tree for the accuracy and stability of many.

History

From single trees to forests

The random forest was developed by Leo Breiman as an algorithm for classification, and it combines two ideas: bagging (bootstrap aggregation) and random variable selection for tree building.⁠[7] The first is the classification tree, a model that splits cases by asking a sequence of yes-or-no questions about their features and ends in a leaf that assigns a class. The second is bagging, short for bootstrap aggregation, in which many copies of a model are trained on random resamples of the data and their outputs are combined. Bagging is a successful approach for combining unstable learners.⁠[7] Breiman's contribution was to add a second dose of randomness on top of it.

A diagram with a matrix X of size 250×100 on the left, branching via a brace into three sampled subsets X1, X2, Xn each of size 60×100 labeled 'Random Sampling with Replacement', each feeding into a small decision tree labeled 'Train', with a brace below the trees labeled 'Aggregate'.
A diagram with a matrix X of size 250×100 on the left, branching via a brace into three sampled subsets X1, X2, Xn each of size 60×100 labeled 'Random Sampling with Replacement', each feeding into a small decision tree labeled 'Train', with a brace below the trees labeled 'Aggregate'. View full-size image.Random Forest Bagging Illustration by Harry585. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The addition is a random restriction at each split. In a forest, each split considers only a random subset of the variables.⁠[7] This small change matters because it decorrelates the trees. Bagging and random variable selection result in low correlation of the individual trees, so the ensemble can achieve both low bias and low variance. Breiman also left each tree unpruned, grown to its full extent, so that individual trees stay low-bias even though they are high-variance; the averaging is what controls the variance.⁠[7]

A random forest can be used when the number of variables is much larger than the number of observations. A random forest can be applied when the number of variables greatly exceeds the number of observations, handles problems with more than two classes, and returns measures of how much each variable contributed to the predictions. Random forest can be applied when the number of variables greatly exceeds the number of observations, handles problems with more than two classes, and returns measures of variable importance.⁠[7] The mechanics of the construction, the error estimate the forest produces internally, and the importance scores are covered later.

How it works

How a random forest is built

Building a forest starts with a single act of resampling. Each tree is grown on a bootstrap sample: a new training set drawn from the original data at random and with replacement, so that some cases appear several times and others not at all. A bootstrap sample of the same size as the original typically contains about two-thirds of the distinct cases; the cases left out are called the out-of-bag samples for that tree.⁠[8] Because every tree gets its own draw, no two trees see quite the same data, and the differences between them are the raw material the forest later averages over.

Four small flowchart-style decision trees are drawn in a 2x2 grid, each with yes/no branches leading to boxes labeled Cancer or Non-cancer, with some leaf boxes shaded green or red.
Four small flowchart-style decision trees are drawn in a 2x2 grid, each with yes/no branches leading to boxes labeled Cancer or Non-cancer, with some leaf boxes shaded green or red. View full-size image.Random Forest Diagram with Four Trees by CollaborativeGeneticist. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The tree itself is grown by recursive partitioning. Starting at the root, the algorithm searches for the split that best separates the cases, and the quality of a candidate split is judged by how much it reduces impurity, a measure of how mixed the classes are in a node. For classification the usual criterion is the Gini index, which is low when a node contains mostly one class; the split chosen is the one that lowers it most.⁠[8] The same procedure is then applied to each resulting child node, and again to its children, until a stopping rule is met. In a random forest the trees are unpruned: growth continues until the terminal nodes, or leaves, are pure, even if a leaf ends up holding a single case, so as to obtain low-bias trees, while bagging and random variable selection keep the trees' correlation low [1, 9].

The randomness enters at every split, not only at the start. When the tree decides how to divide a node, it does not consider all the available variables; it considers a random subset of them, and picks the best split within that subset.⁠[8] The size of that subset is a setting the user chooses (mtry), which calls the most important parameter to choose, though it notes the default value is often a good choice.⁠[7] A low value of mtry increases the chance of selection of features with small effects, which may improve prediction when they would otherwise be masked by features with large effects; a high value reduces the risk of having only non-informative candidate features.⁠[2] This per-split restriction is what keeps the trees from all seizing on the same dominant predictor and becoming near-copies of one another.

Once the forest is grown, prediction is a matter of aggregation. A new case is dropped down every tree, each tree produces an answer, and the forest combines them: for a categorical outcome, the class that receives the most votes wins; for a numeric outcome, the predictions are averaged.⁠[9] No tree is weighted more heavily than another. A single tree is a weak classifier, but the combination of all trees in a forest is a strong classifier, and performance is especially good if the correlations between trees are low [3, 9].

The construction also yields a free estimate of how well the forest will do on new cases. Because each tree was trained without its out-of-bag cases, those cases can be treated as a test set for that tree. Running every case through only the trees that never saw it, and comparing the forest's prediction with the known answer, gives the out-of-bag error, an internal estimate of prediction error that requires no separate holdout set.⁠[9] The same out-of-bag machinery underlies one of the importance scores discussed later: permuting a variable's values and watching how much the out-of-bag accuracy drops reveals how much the forest relied on that variable [8, 9].

Two practical points follow from the construction. Random forest offers an opportunity for efficient parallel processing, and fast implementations such as ranger scale well with the number of features, samples and trees.⁠[10][11] Second, the forest is only as good as the cases it was grown on. RF will lead to biased predictions when trained with data sets that are sampled in a biased way.⁠[12] The construction is mechanical and repeatable, but its output is a summary of the data it was given.

Each tree sees a different resample and a different handful of variables at each split; the forest's accuracy comes from combining many such imperfect, partly independent views.

Measuring what matters: variable importance

A forest that predicts well is useful; a forest that also says which variables drove its predictions is more useful still, because it can point to the measurements that carry the signal. Random forests supply this as a by-product of training, in the form of variable importance measures: scores that rank predictors by how much the fitted forest relied on them. Two measures are in common use, and they are computed in quite different ways.

The first is the Gini importance, also called the mean decrease in impurity. Every time a split is made on a variable, the impurity of the node falls by some amount, and the Gini importance of that variable is the total fall it produced, summed over all the splits in all the trees where it was chosen.⁠[13] A variable that repeatedly produces large, clean separations accumulates a high score. The measure is cheap: the impurity decreases are already computed while the trees are grown, so the ranking costs almost nothing beyond the forest itself.⁠[6]

The second is the permutation importance, which works from the forest's accuracy rather than its structure. The values of one variable are randomly shuffled, breaking any real relationship between that variable and the outcome, and the cases are run through the forest again. If the variable mattered, accuracy drops; if it did not, accuracy barely moves. The drop, averaged over the trees, is the variable's importance.⁠[8] Because it is measured on the out-of-bag cases, the same held-out logic that gives the forest its internal error estimate is reused here.

The two measures usually agree on the broad picture but not on the details, and each has a known failure mode. The Gini importance is biased toward variables that offer many possible split points: a categorical variable with many categories, or a continuous variable, gets more chances to be chosen and so tends to look more important than it is.⁠[5]

Correlation among predictors causes trouble for both. When two variables carry nearly the same information, the forest can lean on either one, and the importance that would have gone to one is split or assigned arbitrarily between them. A variable that is genuinely causal can therefore receive a modest score simply because a close substitute was available and chosen instead. The standard remedy is to compute importance conditional on the other variables, by permuting a variable within a conditioning grid derived from the fitted forest's partition of the feature space, which reflects the variable's own contribution more faithfully than the unconditional version. Even this correction does not remove the preference for correlated predictors entirely, but it gives a fairer comparison.⁠[14]

What the scores are used for follows from what they measure. A ranking of variables by importance is a natural first step in variable selection, the task of reducing a large set of candidate measurements to the few that matter. In a study that integrated over 200,000 genotypes and 153,000 methylation sites in 680 individuals, with simulated causal variants planted among them, the forest ranked most of the strong causal variables highly, though it missed variants with small effects; recursive feature elimination with random forest ranked causal variables poorly when many highly correlated neighbors were present.⁠[3] The scores are best read as a ranking of predictive relevance within the fitted model, not as a verdict on which variables cause the outcome.

Importance scores rank how much the forest leaned on a variable; they are a guide to relevance, not proof of cause.

Two importance scores are computed from the forest in different ways.

Tuning the forest

A random forest has only a handful of settings that the user must choose, and most of them turn out to matter less than intuition suggests. The most important of these to choose is mtry, the number of variables randomly offered as candidates at each split, although its default is often a good choice.⁠[7] A small mtry increases the chance that features with small effects are selected; a large one reduces the risk of having only non-informative candidate features.⁠[2] The other two are ntree, the number of trees grown, and nodesize, the minimum number of cases a terminal node may hold. In the widely used R package randomForest the defaults are mtry equal to the square root of the number of features for classification, ntree of 500, and nodesize of 1.⁠[2]

Figure 1. Error rate and Brier score for standard and tuned random forests. The chart shows the error rate and Brier score for a standard random forest and a tuned random forest on one dataset. The source states: “# little benchmark lrn = makeLearner("classif.ranger", num.trees = 1000, predict.type = "prob") lrn2 = makeLearner("classif.tuneRanger", num.threads = 1, predict.type = "prob") set.seed(354) rdesc = makeResampleDesc("RepCV", reps = 5, folds = 5) bmr = benchmark(list(lrn, lrn2), monk.task, rdesc, measures = list(mmce, multiclass.brier)) bmr # Result # task.id learner.id mmce.test.mean multiclass.brier.test.mean # 1 monk_data classif.ranger 0.01511905 0.1347917 # 2 monk_data classif.tuneRanger 0.00144144 0.0148708 Further parameters In the main function tuneRanger there are several parameters that can be changed.” (Probst et al. (2019)).⁠[16]

Evidence on how much these choices matter comes in part from a systematic sweep. Using nine real microarray data sets plus simulated data, one study varied mtry, ntree and nodesize and found the effects on error rate negligible in most cases, which supports leaving the defaults in place.⁠[7] Two practical recommendations emerged from the same sweep. Execution time grows roughly linearly with ntree, and while larger forests give slightly more stable importance values, 2000 or 5000 trees seemed adequate, with further increases changing little. Raising nodesize from 1 to 5 had negligible effect, so its default of 1 was judged appropriate.⁠[7]

The number of trees deserves a note of its own, because the usual advice to grow as many as time allows is not quite a theorem. The expected error rate can, in principle, rise again after falling as trees are added, so that a minimum appears before the curve turns upward. This non-monotone pattern cannot occur for some other performance measures, such as the Brier score or the mean squared error, and an illustration across 306 public data sets from OpenML showed how far the problem extends in practice. The practical conclusion was to set ntree to a large, computationally feasible value chosen with the behaviour of the measure in mind.⁠[15]

Tuning can still pay. A benchmark on several data sets compared the default forest with forests tuned by model-based optimization, a search procedure that fits a model of the tuning landscape and uses it to pick the next settings to try, and packaged the procedure as tuneRanger. The broader lesson from the same review is that defaults usually work reasonably well but that tuning the hyperparameters can improve performance.⁠[16]

One caution applies to the importance scores rather than to prediction. The permutation importance depends on mtry when predictors are correlated, so a value that is optimal for accuracy may not be the value that gives the fairest ranking of variables. Any reading of importance scores also requires enough trees that results from different random seeds do not vary systematically; only then are differences between measures real rather than noise.⁠[14]

Defaults are a sound starting point; tune when accuracy or a trustworthy variable ranking is worth the extra effort.

Random forests for data that come in groups

The standard forest treats every row of the training table as an independent case. That assumption is invisible when each person, plot or sample appears once, but it breaks when the same unit is measured repeatedly. In a longitudinal study, each subject contributes several observations taken over time, so the rows arrive in clusters and the values within a cluster are correlated: a patient whose blood pressure runs high tends to run high at every visit.⁠[9] The forest has no way to know this from the table alone. It sees many rows and assumes they carry many independent pieces of evidence, when in fact they carry fewer.

Tables of visits for subjects A, B and C connect to a draw of A, A and C, nine training rows, a branching tree and an out-of-bag table containing B's three visits.
Whole subjects are sampled with replacement, keeping all their visits together. The example trains on A, A and C and evaluates on the held-out subject B. View full-size image.Bootstrapping Subjects with Repeated Measurements by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The damage shows up in two places. First, the bootstrap draw for each tree samples rows, not subjects, so a given tree is likely to receive observations from every subject in the study. Trees built that way resemble one another, and the low correlation between trees that the forest depends on is lost.⁠[9] Second, the out-of-bag error becomes too optimistic. A held-out row from a subject whose other rows were in the training set is not really held out, because the tree has already learned that subject's peculiarities; the error estimate is flattered by the resemblance between rows from the same person.⁠[9]

The simplest repair is to collapse each subject to a single row by averaging the repeated measurements. This restores the one-row-per-case structure the forest expects, and it has been used in practice on protein-profiling data from urine samples.⁠[9] The cost is real. Averaging erases the variation within a subject, and it makes every subject count equally regardless of how many times it was measured, which can matter when the number of observations per subject is itself informative.⁠[9]

A cleaner family of fixes moves the randomness from the row level to the subject level. In subject-level bootstrapping, whole subjects are drawn with replacement, and all observations belonging to a chosen subject enter the tree together, avoiding the problem of exposing individual trees to all subjects. A two-stage variant, proposed by Adler et al. and described in, goes further: one subject is chosen randomly with all associated observations in bag, and then for each chosen subject a single observation is randomly selected for that tree's training set. Because different trees are likely to receive different observations from the same subject, the similarity between trees falls further still. Simulation work by Adler et al., as reviewed in, found that a two-stage strategy selecting one observation per subject gave the best predictions compared with the standard forest, the averaging approach and subject-level bootstrapping, though those authors cautioned that other settings could favor other methods.⁠[9]

For a clinical trial this is often the quantity of interest, since the decision concerns the patient, not the visit.

Repeated rows from one subject are not independent evidence; resampling subjects rather than rows keeps the forest's trees different and its error estimate honest.

Random forests for survival and censored outcomes

Not every outcome is a label or a number. In medical follow-up studies the outcome is often a time: how long until a patient dies, relapses, or has a heart attack. Such studies rarely run until every subject has had the event. Some are still healthy when the study ends, and others drop out of contact. For these subjects all that is known is that the event had not yet happened at the last observation. This is right censoring, and it makes the outcome a pair rather than a single value: the time recorded and a flag saying whether the event occurred or the record was cut short.

A standard forest cannot be trained on such pairs directly. Its splitting rule asks which division of the cases makes the child nodes purer, and purity is defined over class labels or over the spread of a numeric response. A censored time is neither. Treating the recorded time as if it were the true event time would quietly count a patient who was alive at the last visit as though the event had happened then, and the tree would learn from invented outcomes.

Random survival forests replace the splitting rule with one built for censored data, using new survival splitting rules designed for censored data.⁠[17] Everything else about the construction carries over from the ordinary forest: each tree is grown on a bootstrap resample, a random subset of variables is offered at each split, and the trees are left unpruned and later aggregated. The method also adds a new missing data algorithm and defines ensemble mortality, a simple interpretable measure of mortality that can be used as a predicted outcome. In a worked case study the authors applied it to the prognostic implications of body mass for individuals with coronary artery disease.⁠[17]

Judging such a model needs its own kind of yardstick, because the usual accuracy score does not apply when outcomes arrive over time and some are never observed. Prediction error curves plot an estimate of prediction error against time, so that a model's performance can be read at every follow-up horizon rather than collapsed into one number. The estimate has to account for censoring; the software implements inverse probability of censoring weights to deal with right censored data. Because a model looks better on the data it was fitted to, the software implements several variants of cross-validation to deal with the apparent error problem.⁠[18]

The comparison that matters is against the established alternative. Using data of the Copenhagen Stroke Study, one evaluation compared random survival forests to a Cox regression model derived from stepwise variable selection using prediction error curves.⁠[18] The framework is general enough to score any prediction model this way, which is part of its value: a forest and a regression model can be placed on the same axis and read at the same time points, instead of being judged by measures that answer different questions.

Censored outcomes need a splitting rule built for them and an error measure that respects the censoring; random survival forests supply the first, prediction error curves the second.

Ordinary splitting cannot use censored pairs, so random survival forests replace the splitting rule.

Research

Evidence from real-world applications

A method's reputation is built less by its design than by what happens when it meets data it did not generate. Random forests have been carried into genomics, soil science, demography, ecology, remote sensing and clinical medicine, and the results across those fields are mixed in an instructive way. The pattern that emerges is not that the forest wins or loses, but that its advantages and its costs depend on the shape of the problem: how many variables there are, how noisy they are, how much the predictions need to be explained, and how much computing time the task can absorb.

Where the forest earns its place

The clearest gains appear where the input is wide and messy and the goal is a prediction rather than a coefficient. Mapping the soil properties of Africa offers a large-scale example. The Africa Soil Information Service assembled more than 28 thousand sampling locations, the most comprehensive soil sample data for the continent, and used them with a large set of environmental covariates to predict properties such as organic carbon, pH, clay fraction and total nitrogen at 250 m resolution. Compared against linear regression under five-fold cross-validation, the random forest cut the root mean squared error by 15 to 75 percent across properties and depths. The gain came at a price: fitting one forest per property took on average 30 to 60 minutes, and producing all the prediction maps required about 10 days of continuous computing on a 12-core workstation.⁠[19] That trade, better accuracy for an order of magnitude more machine time, recurs wherever the forest is applied to large spatial problems.

Population mapping shows the same logic on a different target. To spread census counts across a country at roughly 100 m resolution, one group used a random forest to learn a weighting surface from night-time lights, topography, land cover, climate and distance to roads, schools and health facilities, then redistributed the census totals according to those weights. For Vietnam, Cambodia and Kenya the resulting maps were more accurate than GPW, GRUMP and the AfriPop/AsiaPop products, which rely on areal weighting or on land cover and urban/rural classification. The forest's contribution here was the ability to incorporate many covariates with a minimum of tuning and supervision, including features beyond land cover and climate zone.⁠[20]

Ecology supplies a third setting where the method fits naturally. Comparing random forests with four other common classifiers on data describing invasive plant presence in California, rare lichen presence in the Pacific Northwest, and nest sites of cavity-nesting birds in Utah, one study found high classification accuracy in all three applications, checked by cross-validation and, for the lichen data, by independent test data. The variables the forest flagged as most important for the invasive plants coincided with expectations based on the literature.⁠[21]

When the comparison turns

The picture changes when the forest is set against a method that is well matched to the structure of the data. Microarray cancer classification is the sharpest case. An early evaluation concluded that random forests performed comparably to support vector machines and other classifiers across simulated and nine microarray data sets.⁠[7] A later comparison argued that the earlier work had several methodological biases, including applying the forest to the full gene set while giving the support vector machine only 200 arbitrarily chosen genes, using a weaker multicategory variant, not optimizing the SVM penalty parameter, using a metric sensitive to class imbalance, and skipping any statistical test between classifiers. Redone across 22 diagnostic and prognostic data sets with those limitations removed, the support vector machine had the lower error, both on average and in the majority of data sets, with and without gene selection.⁠[4] The episode is a reminder that a benchmark is only as trustworthy as its design, and that "comparable performance" in one study can become a clear deficit in a better-controlled one.

A large neutral benchmark gives a sense of the average case rather than the extremes. Across 243 real data sets, with the design borrowed from clinical-trial methodology to avoid common biases, the random forest with default settings beat logistic regression on accuracy in about 69 percent of them, with a mean accuracy advantage of 0.029 and a mean improvement in area under the curve of 0.041.⁠[2] The margin is real but modest, and it was measured against a linear model on low-dimensional data, the setting where logistic regression is most at home. The same benchmark noted that the results shifted noticeably depending on which data sets were admitted, which is a caution about reading any single comparison as a general law.

Domain-specific reviews tell a similar story of conditional advantage. In Alzheimer's disease, a systematic review of twelve studies applying random forests to neuroimaging found that the best accuracies, around 90 percent for distinguishing patients from healthy controls, came when the forest was trained on high-dimensional, multi-modal data combining MRI, PET, diffusion imaging and clinical scores. The same review found lower accuracies, around 82 percent, for the binary models distinguishing MCI from healthy controls and stable MCI from progressive MCI, and noted that of the three studies attempting the three-class problem only one reached a reliable accuracy. The forest handled the well-separated problem well and struggled where the classes blur together.⁠[11]

What the applications teach

Read together, these applications suggest where to reach for a random forest and where to hesitate. It is weaker when a simpler model already captures the relationship, as with the linear decision boundaries that support vector machines represent naturally.⁠[4] The cost side is equally consistent: fitting and predicting take substantially more time than linear alternatives, and the results can be sensitive to artifacts in the input data.⁠[19]

One further lesson concerns interpretation. The variable importance scores that come out of these applications can be valuable for interpretation, pointing to spectral regions or brain structures that carry signal [6, 10]. But the same scores can mislead when predictors are correlated, and the applications above are full of correlated predictors. The uses and misuses of those scores, and the broader limits of the method, are taken up later.

Across fields, the forest's edge shows up on wide, noisy, nonlinear problems; on tidy linear ones, a simpler model often matches or beats it.

Random forests for causal inference

Prediction asks what will happen; causal inference asks what would happen if something were changed. The difference matters when a treatment, a policy or an exposure is under consideration, because the question is not who did well but whether the treatment itself helped. A further question sits inside that one: helped whom? A drug may lower risk on average while doing nothing for most patients and a great deal for a few. Estimating that variation is the problem of heterogeneous treatment effects, and it is where a forest can be turned to a purpose other than prediction.

A potential-outcomes table and treatment-effect formula surround three branching trees with purple paths converging on an effect estimate beside an eight-minus-five example.
A new case follows paths through several trees, and the selected leaves contribute to a conditional treatment effect estimate. The worked comparison illustrates a group average effect under identification assumptions. View full-size image.Estimating Effects with Causal Forests by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The obstacle is that a causal effect is never observed for any single case. A patient either received the treatment or did not, so the outcome under the road not taken is missing. What can be estimated, under the assumption that treatment assignment is unrelated to the potential outcomes once the measured covariates are accounted for, is the average difference in outcomes between treated and untreated cases that look alike. One classical approach is nearest-neighbor matching, which pairs each treated case with the untreated cases whose covariates are closest and compares their outcomes.⁠[22]

A causal forest extends Breiman's random forest to estimate heterogeneous treatment effects.⁠[22] The estimate for a new case is then built from the leaves it falls into across the trees, in the same averaging spirit as an ordinary forest.

What distinguishes the causal forest from a heuristic is that its estimates come with guarantees. Under the potential-outcomes framework with unconfoundedness, the estimates are pointwise consistent for the true treatment effect, meaning they converge to it as data accumulate, and their sampling distribution is asymptotically Gaussian and centered on that truth. That second property is what makes confidence intervals possible: the authors give a practical method for constructing asymptotic intervals centered on the forest's estimates. The theory rests on a general result for a broad family of random forest algorithms, and the authors describe it as the first set of results allowing any type of random forest, classification and regression forests included, to be used for provably valid statistical inference.⁠[22]

The practical payoff showed up in experiments. Set against classical nearest-neighbor matching, causal forests were substantially more powerful, and the gap widened when the covariate set contained many variables unrelated to the outcome.⁠[22] The method inherits the forest's tolerance for wide, messy predictor sets and redirects it from predicting outcomes to estimating how effects differ across cases.

A causal forest splits cases so that treatment effects differ between groups, and its estimates come with consistency and confidence intervals rather than a bare ranking.

In practice

Random forests in the sciences

In practice a random forest is rarely the whole of an analysis. It sits inside a workflow, a fixed sequence of steps that takes raw measurements to a finished prediction or a finished list of relevant variables, and the steps around the forest often decide whether the result is trustworthy. A typical workflow has four parts: assemble and quality-check the input data, fit the forest, validate it on cases it did not see, and read off the variable importance scores. Each part has its own failure modes, and the sciences that adopted the method early have learned them the hard way.

The workflow in bioinformatics

Genomics is where the workflow is most developed, because the data are extreme: thousands of genes measured on dozens of samples. A forest handles that shape of problem directly, and its importance scores can be turned into a selection procedure. One widely used approach grows a forest, ranks the genes by importance, removes the weakest fraction, and repeats until a small set remains that still predicts well. Applied to simulated and nine real microarray data sets, this backward-elimination scheme returned very small gene sets, often smaller than competing methods, while keeping predictive accuracy. The procedure adapts the number of genes on its own rather than requiring the analyst to fix a cutoff in advance, which is its main practical advantage over ranking genes by a univariate statistic and keeping the top fifty.⁠[7]

The pitfall in this workflow is instability: different runs, or slightly different training samples, can yield gene lists that predict equally well but share few genes. The same study examined this directly and found the selected sets only partly reproducible, a result it described as slightly disappointing, while noting that competing methods behaved no better and that the causes lie in small sample sizes and the extremely small ratio of samples to genes.⁠[7] The practical response is not to trust a single list but to check whether some genes recur across runs.

Workflows on spatial and ecological data

Spatial prediction adds a step that has nothing to do with trees: deciding how to validate. When the cases are locations, a random split of the data into training and test sets lets the model learn from points adjacent to the ones it is tested on, which flatters the error estimate. A stricter option is spatial declustering of the cross-validation, which may be necessary to get a more realistic measure of mapping accuracy. The same concern applies to the training sample itself: RF will lead to biased predictions when trained with data sets that are sampled in a biased way.⁠[12]

A second spatial pitfall is extrapolation, prediction outside the range of values the forest was trained on. Because a forest's regression predictions are limited to the range of values present in the training observations, it cannot extrapolate beyond that range, and extrapolation with random forests is often not recommended.⁠[20][12] The key to success may be training data quality, especially the quality of spatial sampling, and biased sampling leads to biased predictions.⁠[12]

Ecology illustrates the interpretive payoff of the workflow. Comparing random forests with four other common classifiers on invasive plant presence, rare lichen presence, and bird nest sites, one study found high accuracy across all three, and the variables the forest ranked most important for the invasive plants matched what the botanical literature would have predicted.⁠[21] That agreement is the kind of check that separates a model tracking real signal from one fitting noise.

Reading the output honestly

The last step, interpretation, is where workflows most often go wrong. Importance scores rank variables by how much the fitted forest leaned on them, and that ranking is only as good as the data and the fitting behind it. When predictors are correlated, random forests show a preference for correlated predictor variables, and the choice of the mtry parameter can affect variable importance; correlated predictors also decrease the estimated importance scores of correlated variables.⁠[14][3] Treating the top of the list as a set of causes, rather than as candidates for follow-up, is the commonest overreach.

The forest is one step in a chain; data quality, validation design and cautious reading of the scores decide whether the chain holds.

Extensions for complex data

The standard forest assumes that each case is one independent row of measurements. Many scientific data sets break that assumption: the same patient is measured at several visits, a subject's outcome is a time until an event that may never be observed, a case is a location on a map, or a value is simply missing. Each of these structures has prompted an extension of the algorithm, and the extensions share a common motive: the plain forest either mishandles the dependency or cannot use the information the structure carries.

Four follow-up timelines with event circles and censoring crosses lead to a survival tree, an ensemble of trees and a descending stepped survival curve.
Event and censored follow-up records feed survival trees whose splits separate survival experience. The forest aggregates information to produce the schematic survival curve shown. View full-size image.Survival Forests and Censored Observations by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Repeated measurements

Longitudinal data consist of repeated measurements taken on the same subject over time, which makes the observations clustered and correlated rather than independent. The standard forest assumes observations are drawn independently, and applying it unchanged to such data causes trouble: bootstrap samples for different trees are likely to include observations from every subject, so the trees come out correlated or even near-identical, and the out-of-bag error estimate turns too optimistic because observations from one subject resemble each other. The simplest fix is to average each subject's repeated measurements into a single row, which restores independence but throws away the within-subject variation and makes every subject contribute equally regardless of how often it was measured.⁠[9]

A better family of fixes moves the randomness to the subject level. A two-stage variant first chooses a subject and puts all of its observations in bag, then for each chosen subject randomly selects one observation from its measurements, which the source says could further mitigate the negative effect of intrasubject correlation on prediction performance. These extensions also permit classification at the subject level, by majority vote across that subject's observations, which the source says may be more beneficial and easier to interpret in clinical trials. When the timing of measurements matters, a further extension feeds each tree not only a predictor's current value but its earlier values as well, on the reasoning that a biomarker's history can matter as much as its present level.⁠[9]

Time-to-event outcomes

Survival analysis deals with outcomes that are right-censored: some subjects are followed for a period and never experience the event, so all that is known is that the event had not happened by the last observation. Random survival forests adapt the splitting rule so that nodes are divided by how well they separate survival experience rather than class labels, and they add a missing-data procedure and a summary measure of mortality that can serve as a predicted outcome.⁠[17] The same resampling and aggregation logic carries over; what changes is the criterion the tree optimizes at each split.

Space and causal questions

A forest that ignores location can produce biased predictions, and simply feeding coordinates in as predictors tends to create linear artifacts tied to the sampling layout. The RFsp framework instead derives buffer distances from each observation point and uses them as covariates, which lets the forest learn proximity effects directly; across several data sets it produced predictions about as accurate as ordinary and regression kriging, without requiring a variogram or assumptions about stationarity.⁠[12]

A newer extension turns the forest toward cause rather than prediction. A causal forest estimates how a treatment's effect varies across cases, rather than estimating the treatment's average effect, and under stated assumptions its estimates are consistent and come with a way to build confidence intervals.⁠[22]

Missing values

Real data sets have gaps, and the forest offers a way to fill them. Imputation replaces a missing value with an estimate built from the other variables, and random-forest imputation uses the forest's own machinery to predict the missing entries from the observed ones. Because the method can handle mixed types of missing data and adapts to interactions and nonlinearity, it suits messy data;

Each extension keeps the forest's core of many randomized trees and changes what a tree is grown on, or what it is asked to predict.

Predicting where things are: spatial and spatiotemporal random forests

A map is a prediction at every location, and most locations have never been sampled. A forest trained on soil profiles, weather stations or census tracts can learn from the covariates at each sampled point, but on its own it treats those points as an unordered list. Two sites a hundred metres apart and two sites a thousand kilometres apart are equally unrelated to it. Yet nearby places tend to resemble each other, and a method that ignores this wastes information that is often the strongest available.

A triangle with two five-kilometre sides sits beside two distance surfaces, a covariate table, branching trees and a schematic prediction map.
Distance maps encode proximity to sampled sites and join environmental covariates as forest inputs. The illustrative prediction point is 5 km from each of two sites. View full-size image.Distance Maps for Spatial Forests by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Handing the forest a point's longitude and latitude as two more predictors may not help the prediction process: it leads to linear boundaries in the resulting map (obvious artifacts) which are directly related to the configuration of the sampling plan.⁠[12] What the forest needs is a way to represent proximity itself, not position as a number.

The RFsp framework supplies one. For each observation point it computes a buffer distance map: at every location to be predicted, the distance to that particular training point. These distance maps join the ordinary environmental covariates, and the forest learns from them how strongly a prediction should be pulled toward each nearby observation.⁠[12] Proximity becomes something the trees can split on, and the effect of geography is estimated from the data rather than assumed in advance. The same device extends to time: in the case of spatiotemporal data, RF seems to have the ability to adjust predictions locally in space and time.⁠[12]

The natural yardstick for such a method is kriging, the classical geostatistical technique that models how similarity between locations decays with distance and uses that model to weight nearby observations. Kriging has been used as the best unbiased linear prediction technique for spatial points since the 1960s, and it rests on assumptions about the distribution and stationarity of the target variable and requires defining and fitting a variogram. For many data sets, especially those with a lower number of points and covariates and close-to-linear relationships, model-based geostatistics can still lead to more accurate predictions than RFsp.⁠[12]

Tested against ordinary and regression kriging under five-fold cross-validation with refitting, RFsp often produced predictions about as accurate, and in those cases its cross-validation residuals showed no remaining spatial autocorrelation. It reached that result without a variogram, without a stationarity assumption, and without the analyst specifying a trend or a transformation of the target variable; interactions among covariates are handled by the trees rather than written into a linear term. The framework also accepts covariates of mixed types and in large numbers, and it reports variable importance, so the analyst can see which covariates and which individual observations drove the map. On one data set, zinc in the Meuse valley, the accuracy for RFsp was somewhat smaller than for ordinary kriging, and for many data sets, especially those with a lower number of points and covariates and close-to-linear relationships, model-based geostatistics can still lead to more accurate predictions than RFsp.⁠[12]

The costs are equally concrete. Deriving a buffer distance map for every training point adds a large number of covariates, and computational intensity grows exponentially with increase of calibration data and covariates, so the framework is not recommended for a large number of training points, e.g. ≫1,000.⁠[12] The African soil mapping effort, drawing on a compilation of over 28 thousand sampling locations, illustrates the scale of machine time such work can demand: fitting one random forests model per soil property took on average 30 to 60 minutes, and producing all the prediction maps required about 10 days of continuous computing on a 12-core workstation. Modelling success is sensitive to artifacts in the input data, but as long as quality-controlled point data are provided, an increase in soil mapping accuracy can be expected.⁠[19]

The sharpest limitation is extrapolation, prediction in regions unlike anything in the training data. RF will lead to biased predictions when trained with data sets that are sampled in a biased way, and the key to the success of the RFsp framework might be the training data quality, especially the quality of spatial sampling.⁠[12]

Buffer distances let a forest learn proximity directly; the price is heavy computation and no reliable answer beyond the sampled world.

Choosing among many variable selection methods

A forest hands back a ranking of variables, but a ranking is not a selection. Deciding where to draw the line, and how to keep the variables above it from being an accident of one particular fit, has produced a small industry of procedures. They differ in what they are trying to achieve, and the difference matters more than any single score.

Three black-and-white diagrams of recursive rectangular partitions of a square with axes X1 and X2, including labeled regions A, B, C, D, thresholds t2 and t3, and a binary decision tree with splits X1 > t1, X2 < t2, and X1 < t3.
Three black-and-white diagrams of recursive rectangular partitions of a square with axes X1 and X2, including labeled regions A, B, C, D, thresholds t2 and t3, and a binary decision tree with splits X1 > t1, X2 < t2, and X1 < t3. View full-size image.Recursive Splitting by Rossc0827. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

Two goals are often confused. One is to find a minimal set of variables that predicts well, so that future data collection can be cheap and the model small. The other is to find all the variables that carry real signal, including redundant ones, so that the biology or the process behind the outcome can be understood. A procedure built for the first goal will deliberately drop a variable that duplicates another; a procedure built for the second will keep it, because the duplicate is part of the picture. Recursive feature elimination belongs to the first family: it repeatedly fits a forest, ranks the variables, removes the weakest, and uses the prediction error to select a minimal set of variables needed for a good prediction, so the answer is a compact set tuned to accuracy.⁠[23] The second family works differently, estimating what importance scores look like for variables that carry nothing and keeping those that rise clearly above that noise floor.

The test-based family

Boruta is the best known member of the second family. It adds shuffled copies of every variable, called shadow variables, to the data, grows a forest, and compares each real variable's importance with the distribution of the shadows. Boruta uses shadow variables, that is, permuted versions of the original variables, and a threshold on internally calculated empirical P-values to identify relevant variables.⁠[23] Because the shadows supply an internal null, the procedure needs no external threshold and no assumption about how many variables are relevant.

Vita takes a different route to the same end. It estimates the null distribution of variable importance using the provided predictor variables only, which is valid in high-dimensional settings where many variables are not important for predicting the outcome, and uses a threshold on internally calculated empirical P-values to identify relevant variables.⁠[23] That assumption is what limits it: Vita is designed for high-dimensional settings and is not meant for a table with more cases than columns.

A systematic comparison put these and several others through simulated data with correlated predictors and through methylation and gene expression data sets, alongside permutation importance, its parametric variant, recurrent relative variable importance, and recursive feature elimination.⁠[23] In the simulations, Boruta was the most powerful approach, with Vita close behind, and the two showed similar stability in which variables they chose. Under a pure null model, where no variable was related to the outcome, Vita was the most robust. On the experimental data sets the two were again close, with Vita slightly more stable than Boruta and considerably faster, since it builds two forests whereas the permutation method creates a complete new forest for each permutation.⁠[23]

What the comparison shows

The practical guidance that falls out of this is narrow and useful. For large omics data sets, Boruta and Vita are the recommended choices, and Vita is the faster of the two; Boruta is the one to use when the data are not high-dimensional.⁠[23] Recursive elimination remains a reasonable option when the aim is a small predictive set rather than a complete list, and the comparison treated it as serving that different purpose.

A separate evaluation using 311 classification datasets freely available online reached different conclusions. There, the best methods for most data sets were Jiang's method and the procedure implemented in the VSURF package, while for data sets with many predictors the implementations in varSelRF and Boruta were preferable on grounds of computational efficiency.⁠[24] The two studies asked slightly different questions of slightly different collections of data, and the disagreement is a fair reflection of how much the answer depends on the data at hand.

What both make clear is that the choice of selection procedure is a decision about purpose, not a search for the single best method. A user who wants the smallest set that predicts should say so and pick accordingly; a user who wants to know which variables are involved should pick a procedure built to find all of them, and should expect a longer list and a longer run. Either way, the stability of the chosen set deserves a check, since a list that changes wholesale between runs is not yet a finding.

Selection procedures answer different questions: some seek the smallest predictive set, others seek every variable that carries signal. Pick the one that matches the question.

Alternatives

Random forests versus other methods

No prediction method is best everywhere, and the useful question about a random forest is not whether it wins but where. Its closest rival in ordinary low-dimensional classification is logistic regression, a model that fits a linear relationship between the predictors and the log-odds of the outcome. Logistic regression is transparent, fast, and easy to interpret, but it assumes the relationship has a particular shape. A forest makes no such assumption: it can capture interactions and curved relationships without being told they exist. In a simulation with three constructed problems, one linear, one driven by an interaction between two variables, and one curved, the forest recovered the dependence in the second and third cases while logistic regression, as expected, could not.⁠[2]

The large benchmark described earlier settles the average case rather than the extremes: across 243 real data sets, the forest with default settings beat logistic regression on accuracy in about 69 percent of them, by a mean margin of 0.029.⁠[2] That is a real but modest edge, measured against a linear model on data where a linear model is at home. The same comparison carries a cost that the accuracy figures hide. Logistic regression returns coefficients that say how each predictor moves the outcome; a forest of hundreds of trees returns a prediction and a set of importance scores, and the rule behind any single prediction is hard to state. When the goal is explanation rather than prediction, that difference can outweigh a few points of accuracy.

Against support vector machines, a classifier that finds the boundary separating classes with the widest margin, the forest's record is more mixed and depends heavily on how the comparison is run. On microarray cancer data the two have been set against each other twice with opposite results. An early evaluation found the forest comparable to other classification methods, including DLDA, KNN and SVM, across simulated and nine microarray data sets.⁠[7] A later comparison identified several biases in prior work comparing the two, including giving the support vector machine only 200 arbitrarily chosen genes while the forest saw the full set, and re-ran the contest across 22 diagnostic and prognostic data sets. With those limitations removed, the support vector machine had the lower error, both on average and in the majority of data sets, with and without gene selection.⁠[4] The reversal is a lesson about benchmarks as much as about algorithms: a comparison is only as good as its design, and a method's reputation can rest on a flawed one.

The trade-off between the two is not only accuracy. A forest needs little tuning, while a support vector machine has user-defined parameters such as the penalty setting that must be chosen [13, 22]. One remote-sensing comparison of the two on Landsat data for a seven-class land-cover problem found them equally accurate and equally fast to train, but noted that the forest required fewer user-defined parameters and that those parameters were easier to set.⁠[25] For an analyst without deep expertise in either method, that difference in setup burden is part of the comparison.

In spatial prediction the benchmark is kriging, the classical geostatistical technique that models how similarity between locations decays with distance. Kriging is built on assumptions about the distribution of the target variable and about stationarity, the idea that its statistical properties do not change across the map. The RFsp framework, which feeds buffer distances from observation points into a forest, was compared with ordinary and regression kriging under five-fold cross-validation with refitting. It produced predictions about as accurate as the kriging variants, without requiring a variogram or the stationarity assumptions, and it handled interactions between covariates automatically rather than through a separately specified trend. The same comparison was candid about the limits: on one data set, zinc in the Meuse valley, the forest's accuracy was somewhat lower than ordinary kriging, and for small data sets with close-to-linear relationships, model-based geostatistics can still be more accurate.⁠[12]

Against other classifiers the picture is similarly conditional. In ecology, a comparison with four common classifiers on invasive plant presence, rare lichen presence, and bird nest sites found high accuracy for the forest in all three applications.⁠[21] In Alzheimer's disease, a review of twelve neuroimaging studies found the forest reaching its best accuracies, around 90 percent, on well-separated problems built from multi-modal data, and lower accuracies, around 82 percent, where the classes blur.⁠[11] The pattern across all these comparisons is consistent: the forest's edge appears on wide, noisy, nonlinear problems where the analyst cannot write down the functional form, and it narrows or disappears when a simpler model already matches the data's structure.

The forest rarely wins by a landslide; it wins where the problem is wide, noisy and nonlinear, and loses where a simpler model fits.

Criticism

Limits and criticisms

The case for random forests rests on averaging many imperfect trees, and every limitation follows from that same construction. Averaging cancels errors that are independent across trees; it cannot cancel an error that every tree shares. A biased training sample, a variable whose recorded values are wrong, or a relationship the forest cannot represent will be reproduced faithfully by all the trees and passed on to the ensemble. The forest is a summary of the data it was given, and it inherits that data's flaws without complaint.

The importance scores are not neutral

The most consequential criticism concerns the scores that make the method interpretable. The Gini importance is biased toward variables that offer many possible split points, so categorical variables with many categories and continuous variables tend to look more important than they are. In a simulation where no predictor carried any information, the Gini importance showed a strong preference for variables with many categories and the continuous variable, and in a second simulation with one genuinely informative variable it completely failed to identify that variable.⁠[5] Permutation importance avoids that particular bias but costs far more computing time on wide data, and neither measure is immune to correlation among predictors: when two variables carry nearly the same information, the forest can lean on either, and a genuinely causal variable may receive a modest score because a substitute was chosen instead. A conditional permutation scheme, which shuffles a variable only among cases with similar values of its correlates, reflects each variable's own contribution more faithfully, though it does not eliminate the preference for correlated predictors entirely.⁠[14]

Selected variables do not stay put

A related problem appears when importance scores are used to choose variables. Different runs, or slightly different training samples, can produce lists that predict equally well but share few members. In the microarray gene-selection work, the stability of the selected gene sets was a concern the authors called slightly disappointing, while noting that competing methods did no better and that the causes are small sample sizes and the extremely small ratio of samples to variables.⁠[7] The practical consequence is that a single list should not be treated as a finding; only variables that recur across runs and resamplings deserve confidence.

No extrapolation

Because a forest's prediction is assembled from the training cases, it cannot produce an answer outside the range of values it has seen. On unfamiliar ground it can fail badly rather than degrade gracefully, and for decision-tree methods generally, predictions in regions absent from the training data can be nonsensical.⁠[12] This matters most in spatial and temporal work, where the task is often precisely to predict somewhere new. The same source of fragility applies to input quality: predictions are highly sensitive to artifacts in the data, so quality-controlled measurements matter as much as the algorithm.⁠[19]

The computing bill

The accuracy gains come at a cost in machine time. Fitting one forest per soil property took on average 30 to 60 minutes, and producing all the prediction maps for Africa required about 10 days of continuous computing on a 12-core workstation.⁠[19] Execution time grows roughly linearly with the number of trees, and while 2000 or 5000 trees were judged adequate in the microarray sweep, further increases changed little.⁠[7] Where the forest is one step in a large automated pipeline, that bill is a real constraint on how often models can be refitted.

When a simpler model wins

The forest's edge narrows or vanishes when a simpler model already matches the structure of the data. On 22 microarray cancer data sets, with methodological biases in earlier comparisons corrected, support vector machines had the lower error both on average and in the majority of data sets, with and without gene selection.⁠[4] In spatial prediction, ordinary kriging was somewhat more accurate for zinc in the Meuse data set, and for small data sets with close-to-linear relationships, model-based geostatistics can still do better.⁠[12] The forest also gives up transparency: a forest of hundreds of trees is usually considered a black-box algorithm, and gaining insight on a random forest prediction rule is hard due to the large number of trees.⁠[2]

The forest's weaknesses are the shadow of its strengths: it averages away variance but not shared bias, and it predicts only within the world it was shown.

When random forests meet correlated predictors

Correlation among predictors is the normal condition of measured data, not an exotic defect. Genes on the same chromosome tend to rise and fall together; two soil covariates derived from the same satellite image carry much of the same information; a patient's weight and body mass index are near-duplicates. When a forest meets such a set, it can still predict well, because it only needs some variable that carries the signal. What suffers is the interpretation. The forest has no reason to prefer one member of a correlated group over another, and the importance scores it hands back reflect whichever member the trees happened to split on, not the group's collective contribution.

An original four-row table branches into ordinary and conditional shuffled tables that converge on a forest evaluation panel and an error-difference formula.
Ordinary permutation shuffles X across every row, while conditional permutation shuffles within groups sharing similar Z. Both measure the error change using the same fitted forest. View full-size image.Ordinary and Conditional Permutation Importance by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The mechanism has two parts. The first is a preference built into tree growth: when several correlated predictors are available at a node, the split chosen is likely to fall on one of them, and the choice among near-equivalents is close to arbitrary. The second is subtler and lives in the permutation step. Shuffling the values of one variable while leaving its correlates untouched creates cases that could never occur in real data, and the forest, which can fall back on the untouched correlate, registers only a small loss of accuracy. The variable's apparent importance is therefore diluted by the presence of a stand-in.⁠[14]

The consequence for selection is direct. A variable that genuinely drives the outcome can receive a modest score because a close substitute was chosen instead, and the substitute, which may be biologically incidental, can rank near the top. In an extended simulation study, the unconditional permutation importance attributed a larger share of importance to correlated predictors when those predictors were genuinely associated with the outcome, while remaining unbiased when nothing was associated with it.⁠[26] That pattern is worth pausing on: the measure is not simply noisy, it is systematically generous to redundancy in exactly the situation where a user is most likely to trust it.

Conditioning the permutation

The remedy follows from the diagnosis. If the problem is that a variable is shuffled across the whole data set, the fix is to shuffle it only among cases that are alike in the variables it is correlated with. The conditional permutation importance does this: it partitions the data using the fitted forest's own structure, then permutes a variable's values within each partition, so that its correlates are held roughly fixed and the measured drop in accuracy reflects that variable's own contribution rather than the group's.⁠[14] In the same simulations, the conditional version lowered the scores of correlated predictors relative to the unconditional version and stayed unbiased when no predictor mattered.⁠[26]

The correction is an improvement, not a cure. The conditional scheme reduces the preference for correlated predictors but does not remove it entirely, and it gives a fairer comparison between variables rather than a clean separation of causes.⁠[14] Two practical cautions come with it. The number of trees must be large enough that results from different random seeds do not vary systematically, otherwise differences between the conditional and unconditional scores are partly noise. And the setting that governs how many variables are offered at each split, mtry, changes the ranking when predictors are correlated, so a value chosen for accuracy may not be the value that yields the fairest importance scores.⁠[14]

Why elimination can backfire

A natural response to redundancy is to strip it out: rank the variables, delete the weakest, refit, and repeat. Recursive feature elimination does exactly this, and in smaller data sets it has been found to reduce the pull of correlated variables. Its behaviour changes at high dimension, where the correlated group around a causal variable can be enormous. In a study that integrated 202,919 genotypes and 153,422 methylation sites in 680 individuals, with causal variants and genotype-methylation interactions planted among them, elimination did lower the importance of variables correlated with the causal ones, as intended. But when many variables were highly correlated with a causal variant, it also lowered the causal variant's own importance, so that cause and bystander became equally hard to detect.⁠[3]

The same study found the plain forest, without elimination, ranked most of the simulated causal variables highly, and did so most strongly when those variables had few correlated neighbours.⁠[3] The lesson is not that elimination is useless but that it is a tool for a particular shape of problem. Where correlation is modest and the causal signal is strong, removing redundancy helps. Where a causal variable sits inside a large block of near-duplicates, elimination removes the block and the signal with it, and the honest conclusion is that the data cannot separate the members of that block from one another.

Correlation does not stop a forest from predicting; it stops the importance scores from telling which member of a correlated group is doing the work.

Key studies

YearStudySampleDesignFinding
2007Strobl et al.⁠[5]1000 simulation runsnull case simulation studyThe Gini importance was most strongly biased, and reliable results required an alternative implementation with subsampling without replacement.
2008Strobl et al.⁠[14]500 iterationssimulation studyThe conditional permutation scheme reflected the true impact of each predictor more reliably than the original marginal approach.
2008Ishwaran et al.⁠[17]multiple datasets including breast cancer and transplant datacomparison of random survival forests with Cox regressionIn almost every example, random survival forests that split on the logrank or logrankscore rule gave the smallest prediction error.
2008Statnikov et al.⁠[4]22 diagnostic and prognostic datasetscomparison of random forests and support vector machinesSupport vector machines outperformed random forests in 15 datasets, while random forests outperformed them in 4.
2015Hengl et al.⁠[19]over 28 thousand sampling locationsspatial prediction of soil properties with 5-fold cross-validationRandom forests consistently outperformed linear regression, with average decreases of 15-75% in root mean squared error.
2017Sarica et al.⁠[11]12 articlessystematic reviewApplied to multi-modal neuroimaging data to predict conversion from mild cognitive impairment to Alzheimer's disease, random forest reached some of the best accuracies reported to date.
2018Couronné et al.⁠[2]243 real datasetslarge-scale benchmark experimentRandom forests performed better than logistic regression in approximately 69% of the datasets, with a mean accuracy difference of 0.029.
2018Darst et al.⁠[3]680 individualssimulation study with integrated genotypes and methylation sitesRandom forest found the strong causal variables when only a few correlated variables were present, but it missed other causal variables; recursive feature elimination lowered the importance of the correlated variables and, with many of them, of the causal variables too.
2018Hengl et al.⁠[12]textbook datasets including Meusecomparison of RFsp with kriging using fivefold cross-validationAcross fivefold cross-validation with refitting, the random forest for spatial predictions matched several versions of kriging in accuracy and showed no bias.
2018Zou et al.⁠[1]68994 healthy people and diabetic patientsprediction of diabetes mellitus with five-fold cross-validationRandom forest reached the highest accuracy of 0.8084 when all attributes were used.
2019Probst et al.⁠[16]39 datasetsbenchmark studyTuning random forest hyperparameters with model-based optimization improved the error rate by 0.014 and the Brier score by 0.120 on one dataset.
2019Degenhardt et al.⁠[23]simulated and experimental methylation and gene expression datacomparison of variable selection proceduresBoruta had the most power, with Vita close behind, and Vita held up best under a null model in which no predictor was related to the outcome.

See also

References

  1. Zou, Q., Qu, K., Luo, Y., Yin, D., Ju, Y., & Tang, H. (2018). Predicting Diabetes Mellitus With Machine Learning Techniques. Frontiers in Genetics, 9. doi:10.3389/fgene.2018.00515
  2. Couronné, R., Probst, P., & Boulesteix, A. L. (2018). Random forest versus logistic regression: a large-scale benchmark experiment. BMC Bioinformatics, 19(1). doi:10.1186/s12859-018-2264-5
  3. Darst, B. F., Malecki, K. C., & Engelman, C. D. (2018). Using recursive feature elimination in random forest to account for correlated variables in high dimensional data. BMC Genetics, 19(S1). doi:10.1186/s12863-018-0633-8
  4. Statnikov, A., Wang, L., & Aliferis, C. F. (2008). A comprehensive comparison of random forests and support vector machines for microarray-based cancer classification. BMC Bioinformatics, 9(1). doi:10.1186/1471-2105-9-319
  5. Strobl, C., Boulesteix, A. L., Zeileis, A., & Hothorn, T. (2007). Bias in random forest variable importance measures: Illustrations, sources and a solution. BMC Bioinformatics, 8(1). doi:10.1186/1471-2105-8-25
  6. Nembrini, S., König, I. R., & Wright, M. N. (2018). The revival of the Gini importance? Bioinformatics, 34(21), 3711-3718. doi:10.1093/bioinformatics/bty373
  7. Díaz-Uriarte, R., & Alvarez de Andrés, S. (2006). Gene selection and classification of microarray data using random forest. BMC Bioinformatics, 7(1). doi:10.1186/1471-2105-7-3
  8. Touw, W. G., Bayjanov, J. R., Overmars, L., Backus, L., Boekhorst, J., Wels, M., & van Hijum, S. A. F. T. (2013). Data mining in the Life Sciences with Random Forest: a walk in the park or lost in the jungle? Briefings in Bioinformatics, 14(3), 315-326. doi:10.1093/bib/bbs034
  9. Hu, J., & Szymczak, S. (2023). A review on longitudinal data analysis with random forest. Briefings in Bioinformatics, 24(2). doi:10.1093/bib/bbad002
  10. Wright, M. N., & Ziegler, A. (2017). ranger : A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. Journal of Statistical Software, 77(1). doi:10.18637/jss.v077.i01
  11. Sarica, A., Cerasa, A., & Quattrone, A. (2017). Random Forest Algorithm for the Classification of Neuroimaging Data in Alzheimer's Disease: A Systematic Review. Frontiers in Aging Neuroscience, 9. doi:10.3389/fnagi.2017.00329
  12. Hengl, T., Nussbaum, M., Wright, M. N., Heuvelink, G. B. M., & Gräler, B. (2018). Random forest as a generic framework for predictive modeling of spatial and spatio-temporal variables. PeerJ, 6, e5518. doi:10.7717/peerj.5518
  13. Menze, B. H., Kelm, B. M., Masuch, R., Himmelreich, U., Bachert, P., Petrich, W., & Hamprecht, F. A. (2009). A comparison of random forest and its Gini importance with standard chemometric methods for the feature selection and classification of spectral data. BMC Bioinformatics, 10(1). doi:10.1186/1471-2105-10-213
  14. Strobl, C., Boulesteix, A. L., Kneib, T., Augustin, T., & Zeileis, A. (2008). Conditional variable importance for random forests. BMC Bioinformatics, 9(1). doi:10.1186/1471-2105-9-307
  15. Probst, P., & Boulesteix, A. (2017). To tune or not to tune the number of trees in random forest? arXiv. doi:10.48550/arxiv.1705.05654 Free full text
  16. Probst, P., Wright, M. N., & Boulesteix, A. (2019). Hyperparameters and tuning strategies for random forest. WIREs Data Mining and Knowledge Discovery, 9(3). doi:10.1002/widm.1301
  17. Ishwaran, H., Kogalur, U. B., Blackstone, E. H., & Lauer, M. S. (2008). Random survival forests. The Annals of Applied Statistics, 2(3), 841-860. doi:10.1214/08-aoas169
  18. Mogensen, U. B., Ishwaran, H., & Gerds, T. A. (2012). Evaluating Random Forests for Survival Analysis Using Prediction Error Curves. Journal of Statistical Software, 50(11). doi:10.18637/jss.v050.i11
  19. Hengl, T., Heuvelink, G. B. M., Kempen, B., Leenaars, J. G. B., Walsh, M. G., Shepherd, K. D., Sila, A., MacMillan, R. A., Mendes de Jesus, J., Tamene, L., & Tondoh, J. E. (2015). Mapping Soil Properties of Africa at 250 m Resolution: Random Forests Significantly Improve Current Predictions. PLOS ONE, 10(6), e0125814. doi:10.1371/journal.pone.0125814
  20. Stevens, F. R., Gaughan, A. E., Linard, C., & Tatem, A. J. (2015). Disaggregating Census Data for Population Mapping Using Random Forests with Remotely-Sensed and Ancillary Data. PLOS ONE, 10(2), e0107042. doi:10.1371/journal.pone.0107042
  21. Cutler, D. R., Edwards, T. C., Beard, K. H., Cutler, A., Hess, K. T., Gibson, J., & Lawler, J. J. (2007). Random forests for classification in ecology. Ecology, 88(11), 2783-2792. doi:10.1890/07-0539.1
  22. Wager, S., & Athey, S. (2018). Estimation and Inference of Heterogeneous Treatment Effects using Random Forests. Journal of the American Statistical Association, 113(523), 1228-1242. doi:10.1080/01621459.2017.1319839
  23. Degenhardt, F., Seifert, S., & Szymczak, S. (2019). Evaluation of variable selection methods for random forests and omics data sets. Briefings in Bioinformatics, 20(2), 492-503. doi:10.1093/bib/bbx124
  24. Speiser, J. L., Miller, M. E., Tooze, J., & Ip, E. (2019). A comparison of random forest variable selection methods for classification prediction modeling. Expert Systems with Applications, 134, 93-101. doi:10.1016/j.eswa.2019.05.028
  25. Pal, M. (2005). Random forest classifier for remote sensing classification. International Journal of Remote Sensing, 26(1), 217-222. doi:10.1080/01431160412331269698
  26. Nicodemus, K. K., Malley, J. D., Strobl, C., & Ziegler, A. (2010). The behaviour of random forest permutation-based variable importance measures under predictor correlation. BMC Bioinformatics, 11(1). doi:10.1186/1471-2105-11-110

Cite this page: Atlas Nova editors. (2026). Random forest. Atlas Nova. https://velocer.io/atlas/random-forests/