Tutorials › Exam PA - Predictive Analytics › Variable Importance In Boosted Trees

Exam PA · Gradient Boosting and Tuning · Tutorial 574 of 966

Variable Importance In Boosted Trees

Calculate and interpret split-based and gain-based importance while recognizing what these summaries can—and cannot—say about predictors.

Advanced 11 min read

What You'll Learn

  • Define split counts, split frequencies, total gain, and average gain for a boosted-tree ensemble
  • Calculate split-based and gain-based importance from tree-level summaries
  • Derive squared-error split gain from parent and child node losses
  • Distinguish raw gain from normalized gain shares and implementation-specific importance measures
  • Explain why importance rankings depend on the fitted model and do not establish causal effects

Why Variable Importance Needs a Definition

A boosted-tree model may use a predictor in many splits, or use it only a few times where it produces substantial reductions in the fitting objective. These are different notions of “importance.” A split-based summary describes how often a predictor was selected; a gain-based summary describes how much objective improvement is attributed to its splits under a stated convention. Neither summary, by itself, says whether a predictor raises or lowers predictions, nor whether changing the predictor would cause an outcome to change.

For an ensemble, each tree is added after the current model has already been updated by earlier trees. A split’s gain is therefore assessed in the context of the model and fitting procedure at that stage. The resulting importance is a description of the fitted ensemble, not a general property of the predictor. The definitions below are aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Definition: An internal split node is a node in a tree that divides its observations according to a predictor. For predictor \(j\), its split count \(N_j\) is the number of internal nodes, across the selected trees, that split on \(j\). Its split frequency is \(N_j\) divided by the total number of internal split nodes. A split gain is the reduction in a specified fitting objective attributed to a split. The total gain \(G_j\) for \(j\) is the sum of its split gains under the chosen convention.

The word “importance” is not enough to identify a calculation. A table may report raw split counts, percentages of splits, sums of gains, average gain per split, or normalized gain shares. These measures answer different questions and need not produce the same ranking. Always identify which quantity is being reported and which trees, iterations, objective, and gain convention were used.

Split-Based and Gain-Based Summaries

Suppose the model contains \(M\) fitted trees. Let \(\mathcal{S}_j\) be the set of their internal nodes that split on predictor \(j\), and let \(\Delta_s\) denote the gain assigned to node \(s\). If \(K\) is the total number of internal split nodes across the selected trees, then the principal summaries are:

$$ N_j=|\mathcal{S}_j|,\qquad F_j=\frac{N_j}{K},\qquad G_j=\sum_{s\in\mathcal{S}_j}\Delta_s. $$

The split frequency \(F_j\) is often displayed as \(100F_j\%\). A gain share can similarly be defined as \(G_j/\sum_k G_k\), provided the total gain in the denominator is positive and all gains use the same convention. Some reports instead show average gain, \(G_j/N_j\), for predictors with \(N_j>0\). The average describes the mean gain at a predictor’s selected splits; it is not the predictor’s total contribution across the ensemble.

Gain is implementation-dependent. For a regression tree using squared-error loss, it may be defined as the reduction in residual sum of squares. In gradient-boosting software, it may instead use an objective-specific split score, potentially including weights, gradients, Hessians, or regularization terms. Thus, a reported gain is meaningful only with its fitting objective and software convention understood. For the hand calculations below, the stated gain definition is the unpenalized reduction in the specified loss.

Worked Example: Comparing Split Frequency With Total Gain

A hypothetical claims-cost model uses three predictors: vehicle age, territory, and prior claim count. Across its selected trees, the recorded splits are: vehicle age has gains 8, 4, and 2; territory has gains 5 and 3; prior claim count has gain 6. Calculate split counts, split frequencies, total gains, normalized gain shares, and average gains. State what each ranking says.

Method and split counts. Count each internal node once. Vehicle age has \(N_{\text{age}}=3\) splits, territory has \(N_{\text{territory}}=2\), and prior claim count has \(N_{\text{prior}}=1\). The total is \(K=3+2+1=6\).

Split frequencies. Divide each count by 6: vehicle age has \(3/6=0.5000\), territory has \(2/6=0.3333\), and prior claim count has \(1/6=0.1667\). As percentages, these are 50.00%, 33.33%, and 16.67%; they sum to 100.00%.

Total gains. Add the gains for each predictor: vehicle age has \(8+4+2=14\); territory has \(5+3=8\); prior claim count has \(6\). Total gain is \(14+8+6=28\).

Normalized gain shares. Divide by 28: vehicle age has \(14/28=0.5000\), territory has \(8/28=0.2857\), and prior claim count has \(6/28=0.2143\). As percentages, these are 50.00%, 28.57%, and 21.43%, which sum to 100.00%.

Average gain per split. Divide each total by its split count: vehicle age has \(14/3=4.6667\), territory has \(8/2=4.0000\), and prior claim count has \(6/1=6.0000\). Vehicle age ranks first by frequency and total gain, while prior claim count ranks first by average gain per split. The calculations check because total gain sums to 28 and split percentages sum to 100%. The common mistake is to call the largest average gain the largest total contribution.

Why Squared-Error Gain Has This Form

For a regression tree using squared-error loss, suppose a parent node contains \(n=n_L+n_R\) observations with response mean \(\bar{y}\). A proposed split creates left and right child means \(\bar{y}_L\) and \(\bar{y}_R\). The parent predicts \(\bar{y}\) for every observation in that node, while each child predicts its own mean. Define each node’s loss as the sum of squared deviations from that node’s mean. Under these assumptions, the split gain is the parent loss minus the sum of the child losses.

$$ \begin{aligned} \sum_{i\in P}(y_i-\bar{y})^2 &= \sum_{i\in L}(y_i-\bar{y}_L)^2 +\sum_{i\in R}(y_i-\bar{y}_R)^2\\ &\quad+n_L(\bar{y}_L-\bar{y})^2+n_R(\bar{y}_R-\bar{y})^2\\ &= \sum_{i\in L}(y_i-\bar{y}_L)^2 +\sum_{i\in R}(y_i-\bar{y}_R)^2 +\frac{n_Ln_R}{n}(\bar{y}_L-\bar{y}_R)^2. \end{aligned} $$

For the first equality, write each deviation as \(y_i-\bar{y}=(y_i-\bar{y}_L)+(\bar{y}_L-\bar{y})\) in the left child, and analogously in the right child. On squaring and summing within a child, the cross term is zero because deviations from that child’s mean sum to zero. For the second equality, the parent mean is \(\bar{y}=(n_L\bar{y}_L+n_R\bar{y}_R)/n\). Hence \(\bar{y}_L-\bar{y}=(n_R/n)(\bar{y}_L-\bar{y}_R)\) and \(\bar{y}_R-\bar{y}=-(n_L/n)(\bar{y}_L-\bar{y}_R)\). Substitution gives the final term. Therefore the squared-error gain is nonnegative and equals that final term. This identity assumes unweighted squared-error loss and child predictions equal to their sample means; it is not a general gain formula for every boosting objective.

Worked Example: Calculating the Gain of a Regression Split

A hypothetical tree considers splitting eight policy records into two groups using a predictor. The responses in the left child are 2, 4, 4, 6, and those in the right child are 7, 9, 9, 11, measured in thousands of dollars. Use unweighted squared-error loss and predict each node by its mean. Calculate the parent and child losses and verify the gain using the mean-difference identity.

Method and child means. The left mean is \((2+4+4+6)/4=16/4=4\). Its squared-error loss is \((2-4)^2+(4-4)^2+(4-4)^2+(6-4)^2=4+0+0+4=8\). The right mean is \((7+9+9+11)/4=36/4=9\), and its loss is \((7-9)^2+(9-9)^2+(9-9)^2+(11-9)^2=4+0+0+4=8\). The combined child loss is \(8+8=16\).

Parent loss. The parent mean is \((16+36)/8=52/8=6.5\). Its loss is \(20.25+6.25+6.25+0.25+0.25+6.25+6.25+20.25=66\). The split’s squared-error gain is therefore \(66-16=50\) in squared thousands-of-dollars units.

Identity check. Here \(n_L=n_R=4\), \(n=8\), and the child means differ by \(9-4=5\). The identity gives \((4\cdot4/8)(5^2)=2\cdot25=50\), matching the loss subtraction. The common mistake is to compare the parent loss with just one child’s loss; the correct comparison is parent loss minus the sum of both child losses.

What Importance Values Do and Do Not Establish

Split frequency and gain are useful for describing how a particular fitted model used its available predictors. A high split count means a predictor was selected at many internal nodes, not necessarily that those nodes produced large improvements. A high total gain means its selected splits accumulated a large amount under the stated gain convention; it does not reveal the direction of prediction changes. For logistic boosting, for example, a gain based on the fitting objective is not automatically a change of the same size in predicted probability.

The values are conditional on modeling choices. Changing the training sample, tree depth, number of boosting iterations, learning rate, regularization, or available predictors can change which splits are selected and their gains. Correlated predictors may offer similar information; a tree can select one in a particular fit and assign it gain that another fit assigns to its correlate. A predictor with many possible split points or categories may also have more opportunities to be selected, depending on the implementation and its handling of predictors.

Most importantly, neither split count nor gain supports a causal conclusion. The fact that a predictor appears frequently or receives substantial gain does not show that intervening on it would change the outcome. The model may be using a proxy, exploiting an association created by confounding or selection, or capturing a predictive relationship that is not causal. A causal claim requires an appropriate study design and assumptions beyond a predictive importance table.

Worked Example: Importance Can Shift Between Correlated Predictors

Two hypothetical boosted models predict the same renewal-cost outcome. The predictors A and B are strongly associated in the training data, and their validation performance is nearly identical. In Model 1, A has split gains 18, 12, and 6; B has gain 4; and C has gains 8 and 4. In Model 2, A has gain 8; B has gains 17, 13, and 6; and C again has gains 8 and 4. For each model, compute split counts, gain totals, and normalized gain shares, then interpret the change.

Model 1. Split counts are \(N_A=3\), \(N_B=1\), and \(N_C=2\), for \(K=6\). Total gains are \(G_A=18+12+6=36\), \(G_B=4\), and \(G_C=8+4=12\), giving total gain \(36+4+12=52\). Gain shares are \(36/52=0.6923\), \(4/52=0.0769\), and \(12/52=0.2308\), or 69.23%, 7.69%, and 23.08%.

Model 2. Counts are \(N_A=1\), \(N_B=3\), and \(N_C=2\), again totaling 6. Gains are \(G_A=8\), \(G_B=17+13+6=36\), and \(G_C=12\), for total gain \(8+36+12=56\). Shares are \(8/56=0.1429\), \(36/56=0.6429\), and \(12/56=0.2143\), or 14.29%, 64.29%, and 21.43%.

Interpretation and check. Model 1 assigns the largest gain share to A; Model 2 assigns the largest share to B. In each model, the gain shares sum to 100%, and A and B together receive \(48/52=92.31\%\) in Model 1 and \(44/56=78.57\%\) in Model 2. Similar predictive performance does not require the two correlated predictors to receive identical individual importance. This is a model-allocation result, not evidence that A or B causes renewal cost.

Reading an Importance Table Carefully

When reporting an importance summary, state the measure and its scope. For example, “split frequency among the first 120 trees” is more precise than “importance.” If reporting gain, clarify whether it is a raw sum, an average per split, or a normalized share, and whether the implementation’s gain includes objective-specific or regularization terms. Software packages do not necessarily use identical definitions: an implementation may report relative influence or normalize a gain-based total, while another may expose split counts and objective-score gains.

A disciplined interpretation keeps three questions separate:

  • Usage: How often did the fitted trees split on this predictor?
  • Objective reduction: How much gain was assigned to those splits under the stated definition?
  • Substantive meaning: What, if anything, can be concluded about direction, mechanism, or causation? Importance alone does not answer these questions.

Importance summaries are most useful as compact diagnostics or communication aids when their definitions and limitations are explicit. They can help identify predictors the fitted ensemble relied on, but should not be presented as a universal ranking of variables or as proof of causal influence.

Key takeaway: Split-based importance counts where a predictor was used; gain-based importance totals the objective reduction assigned to its splits. Specify the convention, distinguish totals from averages and shares, and treat every importance value as a property of the fitted model—not as a causal effect.

Check Your Understanding

For each original problem, identify the requested importance convention before calculating.

  1. A fitted ensemble has 10 internal split nodes: predictor R appears 4 times and predictor S appears 6 times. What are their split frequencies? (Answer: R = 40%; S = 60%.)
  2. Predictor P has split gains 3, 7, and 2; Q has gains 8 and 4. Find each total gain and normalized gain share. (Answer: \(G_P=12\), \(G_Q=12\); each gain share is 50%.)
  3. A squared-error parent node has 10 observations. A split creates children of sizes 4 and 6 with means 5 and 8. Using the mean-difference identity, calculate the gain. (Answer: \((4\cdot6/10)(8-5)^2=21.6\).)
  4. Predictor W has four splits with gains 2, 4, 6, and 8. Predictor Z has two splits with gains 9 and 7. Which predictor has greater split frequency, total gain, and average gain per split? (Answer: W has greater split frequency (4 vs. 2) and total gain (20 vs. 16); Z has greater average gain (8 vs. 5).)
  5. A model assigns substantial gain to a predictor that is associated with an outcome, and the predictor is correlated with another available feature. Does its importance establish that changing the predictor would change the outcome? State the reason. (Answer: No; importance describes the fitted model’s predictive split use and does not establish a causal effect.)
Clinical Biostats