Why the Number of Candidate Predictors Matters
At each split in a random forest, a tree considers only a randomly selected subset of the available predictors. The number in that subset is called mtry. It controls how many opportunities a split has to use a strong predictor, and how much randomness remains between trees. Choosing mtry is therefore a balance: a larger candidate set may make stronger splits easier to find, while a smaller one generally makes the trees’ split decisions less alike.
The right balance depends on the data and the prediction task. Common classification and regression defaults give useful starting points, but they do not guarantee the best forest for a particular problem. This tutorial develops the trade-off and the probability calculations that help explain it. The discussion is aligned with the SOA Exam PA (Predictive Analytics) syllabus.
A candidate predictor is not the same thing as a candidate split point. For example, a numerical predictor might offer several possible cut points. The mtry selection determines whether that predictor is considered at all; the tree’s split-search procedure then assesses its possible splits. For classification trees, the assessment commonly uses an impurity measure such as Gini impurity. For regression trees, it commonly uses reduction in squared error.
Unless noted otherwise, probability calculations below assume that the \(m\) candidates are selected uniformly without replacement from the \(p\) available predictors. They also assume that the same set of \(p\) predictors is eligible at the node and that the predictors called useful are fixed for the calculation. These assumptions make the candidate set a simple random sample; implementations or data conditions that change eligibility can alter the calculation.
Common Starting Rules
Two widely used rules of thumb are:
- Classification: start with \(m\) near \(\sqrt{p}\).
- Regression: start with \(m\) near \(p/3\).
These are starting conventions, not mathematical optima. The software must use an integer between 1 and \(p\), so it has to apply an integer rule to a non-integer result. Packages and versions can differ in their defaults and rounding conventions. In practice, check the software’s documented default and the fitted model’s reported setting rather than assuming that every implementation makes the same choice.
Increasing \(m\) makes it more likely that a strong predictor is available to a node. It also gives the tree a larger pool from which to choose its split. Reducing \(m\) adds randomization: even two trees seeing similar observations may receive different candidate predictors and therefore make different split decisions. This can reduce similarity among trees, although it can also make a particular tree’s split weaker. Neither effect alone determines the forest’s predictive performance.
Worked Example: A Classification Starting Value and Useful-Predictor Coverage
A hypothetical classification forest has \(p=25\) eligible predictors. Two are considered useful for separating the outcome classes at a particular node. Using the square-root starting rule, find \(m\), then calculate the probability that the candidate set contains at least one useful predictor.
Method. Use the classification rule to choose a candidate count, then use the complement of the event that neither useful predictor is selected. The calculation avoids treating the two predictors’ inclusion events as independent.
Candidate count. The square root of 25 is 5, so \(m=5\). There are \(\binom{25}{5}\) possible candidate sets of size 5. To select no useful predictor, all five must come from the 23 predictors that are not useful, giving \(\binom{23}{5}\) sets.
Probability of no useful predictor.
The probability of selecting at least one useful predictor is the complementary probability:
Check. The two probabilities add to \(0.6333+0.3667=1.0000\), allowing for the displayed rounding. The answer describes the candidate set at one node; it does not say whether the selected predictor will produce the best split.
Probability of Including a Useful Predictor
More generally, suppose \(k\) of the \(p\) predictors are useful at a node, and \(m\) predictors are sampled without replacement. “Useful” here means useful for the split opportunity under consideration; it does not imply that the predictor is useful at every node or that it will be chosen as the final split.
The numerator counts candidate sets containing only predictors from the \(p-k\) non-useful predictors. The denominator counts all candidate sets of size \(m\). Their ratio is the probability of getting a set with no useful predictor; subtracting from 1 gives the probability of the complementary event.
This formula also shows why coverage rises with \(m\): increasing the number drawn makes it harder to form a candidate set consisting entirely of non-useful predictors. But coverage is not the only consideration. If one predictor is exceptionally strong, a small \(m\) may often omit it. If many predictors carry similar information, a smaller \(m\) may still provide useful candidates while introducing more variation in the trees’ choices.
Worked Example: A Regression Starting Value with Two Useful Predictors
A hypothetical regression forest has \(p=9\) predictors, of which \(k=2\) are useful for reducing squared error at a node. Use the common regression starting rule \(m=p/3\), then find the probability that at least one useful predictor is selected.
Method. Apply the regression rule, count candidate sets that exclude both useful predictors, and subtract that probability from 1. This avoids confusing the chance of including a useful predictor with the chance of excluding one.
Candidate count.
There are \(\binom{9}{3}=84\) candidate sets. If neither useful predictor is selected, all three candidates must come from the seven non-useful predictors, giving \(\binom{7}{3}=35\) such sets.
Probability of at least one useful predictor.
Check. The probability of selecting neither is \(35/84=0.4167\) to four decimal places. Adding the two complementary probabilities gives \(0.4167+0.5833=1.0000\). The result is a chance of candidate coverage, not a guarantee that the tree will select a useful predictor for its split.
How mtry Changes Split Strength and Tree Diversity
At a given node, imagine listing the split improvements available from all eligible predictors, with each predictor’s best valid split represented by its improvement under the tree’s criterion. If the same data, eligibility rules, and split-search method are held fixed, considering more predictors cannot reduce the best improvement available: the larger candidate set contains more options to compare. This is an opportunity statement, not a claim that every realized forest with larger \(m\) will perform better.
The justification is direct. Let \(C_1\) be a candidate set contained in a larger candidate set \(C_2\). The maximum improvement among predictors in \(C_1\) is no greater than the maximum among predictors in \(C_2\), because every option in \(C_1\) is also available in \(C_2\). Random candidate sets of different sizes are not necessarily nested in an actual fit, so this comparison explains the mechanism rather than proving a point-by-point ordering of two fitted forests.
A larger \(m\) also makes it more likely that a high-value predictor is repeatedly available. If one predictor dominates, many trees may select it near the top of their structure. Smaller \(m\) makes its omission more likely at any given node and gives other predictors more opportunities to shape the trees. This can reduce tree-to-tree similarity, a consideration connected to the earlier material on tree correlation and ensemble variance. However, a smaller candidate set can also make useful splits less accessible, especially when only a few predictors carry signal.
Worked Example: Comparing Candidate Counts for the Same Node
A hypothetical classification problem has \(p=12\) predictors, of which \(k=3\) are useful at a particular node. Compare the chance of including at least one useful predictor when \(m=3\), \(m=6\), and \(m=12\). Treat these as alternative candidate-count choices, not as three stages of one forest.
Method. For each choice, use \(1-\binom{p-k}{m}/\binom{p}{m}\). The number of non-useful predictors is \(12-3=9\).
When \(m=3\): There are \(\binom{12}{3}=220\) candidate sets. Of these, \(\binom{9}{3}=84\) omit all useful predictors.
When \(m=6\): There are \(\binom{12}{6}=924\) candidate sets, of which \(\binom{9}{6}=84\) omit all three useful predictors.
When \(m=12\): All predictors are candidates, so all three useful predictors are included and the probability is 1.
Check and interpretation. Coverage increases from \(0.6182\) to \(0.9091\) to \(1\) as \(m\) increases. The calculation establishes that useful-predictor access improves for this node. It does not establish that \(m=12\) gives the best forest: using every predictor removes this source of randomization and may make trees more alike.
Choosing and Interpreting a Starting Value
The classification square-root rule and regression one-third rule are practical defaults, not consequences of a theorem that identifies the best value. A useful interpretation is: begin with a conventional candidate count, then assess whether that setting provides an adequate balance between useful splits and tree diversity for the particular prediction problem. The best balance depends on the number of predictors, how concentrated the predictive signal is, relationships among predictors, and the split criteria and other forest settings.
A larger candidate count is especially attractive when important signal is sparse: if only one or two predictors matter among many, a very small \(m\) can often omit them at a node. A smaller count can be attractive when many predictors provide comparable signal or when excessive similarity among trees is a concern. These are reasons to consider a value, not rules that determine the winner. Predictive performance must be judged using an appropriate validation design; an in-sample split improvement is not a substitute for that assessment.
When comparing candidate counts, keep the interpretation clear. A change in \(m\) changes the random subset available at each split; it does not change the number \(p\) of predictors in the data. Nor does a higher probability of including a useful predictor automatically mean a proportionally lower prediction error. Trees make many dependent decisions, and forest performance reflects the combined effect of those decisions.
Common Exam Traps
- Using the wrong complement. The ratio \(\binom{p-k}{m}/\binom{p}{m}\) is the probability of selecting no useful predictors, not the probability of selecting at least one. Subtract it from 1 for the latter.
- Assuming independent inclusion. Sampling \(m\) distinct predictors without replacement means selections are dependent. Use the combination formula rather than treating each draw as an independent trial.
- Confusing \(p\) and \(m\). \(p\) is the total number of eligible predictors; \(m\) is the number considered at one node. A default rule is applied to \(p\), not to the number of useful predictors.
- Calling a common rule universally optimal. The square-root and one-third rules are starting conventions. Their use alone does not prove that a forest has the best predictive performance.
- Ignoring integer conventions. Since \(m\) must be an integer between 1 and \(p\), check how the implementation converts a fractional rule to an integer.
Check Your Understanding
For the probability questions, assume uniform sampling without replacement from all \(p\) predictors at the node. Give probabilities to four decimal places.
- A classification problem has \(p=16\) predictors and uses the square-root starting rule. If one predictor is useful at a node, find \(m\) and the probability it is included. (Answer: \(m=4\); probability \(=4/16=0.2500\).)
- A regression problem has \(p=12\) predictors and uses \(m=p/3\). If two predictors are useful, find the probability that at least one is included. (Answer: \(m=4\); \(1-\binom{10}{4}/\binom{12}{4}=1-210/495=19/33=0.5758\).)
- There are \(p=10\) predictors, \(k=3\) of which are useful, and \(m=5\). Find the probability that at least one useful predictor is selected. (Answer: \(1-\binom{7}{5}/\binom{10}{5}=1-21/252=11/12=0.9167\).)
- At a node, \(p=20\), \(k=2\), and \(m=4\). Find the probability that at least one useful predictor is selected. (Answer: \(1-\binom{18}{4}/\binom{20}{4}=1-3060/4845=7/19=0.3684\).)
- A colleague argues that using \(m=p\) must give the best forest because every useful predictor is available at every split. State the valid implication of \(m=p\) and one reason it does not prove the claim. (Answer: Every eligible predictor is considered at each node, so useful-predictor coverage is 1; this does not prove best forest performance because the added randomization from smaller \(m\) may reduce similarity among trees, and performance depends on the problem and must be assessed.)