# _Applied Sciences_
## 2 The Gbt-HIPS Method
### Redistribute Path Weight, Split the Paths, and Aggregate the Nodes  
This second step is critical for assigning importance scores to the decision nodes. The path's weight is the absolute value returned by the path's terminal node. The path weights represent each individual tree's contribution to the log odds prediction and must be fairly distributed over each decision node in the path. The redistribution must take into account the node order in the originating path as well as the predictive power of the node itself. The KL-divergence, also known as relative entropy, is ideal for this purpose because it measures information gained if a new distribution (\(P\)) is used, instead of a reference distribution (\(P^{\prime}\)). The KL-divergence is calculated as follows:  
\[D_{KL}(P\parallel P^{\prime})=-\sum_{k=1}^{K}P\log\biggl{(}\frac{P}{P^{\prime }}\biggr{)} \tag{1}\]  
where \(P\) is the distribution of class labels for instances that reach a given node in the path and \(P^{\prime}\) is the distribution that reaches the previous node in the path. In the case of the root node, which is first in the path, \(P^{\prime}\) is simply the prior distribution. Here, the quantities are estimated using the training set or any other large i.i.d. sample. Once the relative entropy for the last decision node in the path is evaluated, the values for the entire path are normalised, such that their total is equal to that of the path weight. The paths are then disaggregated into the individual, weighted decision nodes and stored in a key-value dictionary, with the decision nodes as keys and the redistributed path weights as values. The weights for identical nodes are aggregated by summation as they enter the dictionary. While this operation is straightforward for nodes that represent discrete or categorical features, there is a complication with nodes that act on continuous features that is a natural consequence of GBT training. On each training iteration, the instances are re-weighted, which alters the target distribution. See [1] for further details. A further perturbation occurs in the very common stochastic GBT variant. Stochastic GBT takes random samples of training instances on each iteration, in addition to the aforementioned re-weighting. Hence, when a new decision tree is induced over the modified distribution, the exact location at which continuous features might be partitioned can move from one iteration to the next in a non-deterministic manner. That is to say, many unique values may all represent the same decision boundary. Competing methods (such as LIME, Anchors, SHAP and the IML models) avoid this problem by preprocessing the continuous features into arbitrary, quartile bins. There are several problems with this approach, not least of which is a loss of information because the quartile bin medians are very unlikely to align with the optimal boundary values. gbt-HIPS instead delegates this discretisation step to the GBT model training. More specifically, it is the information theoretic step of decision tree induction that determines the location of each split in the continuous variables. gbt-HIPS applies a simple binning function to all the extracted decision node boundary values for each continuous feature. This idea is illustrated in Figure 2. In this toy example, the data set shown has one feature, \(x1\) and two classes. The negative class \(-\) (blue) is found mostly around the middle of the range of \(x1\) and is completely enclosed by the positive class \(+\) (grey). A GBT model is trained for 1000 iterations using decision trees with \(maxdepth=2\), allowing each tree to find two boundary values. The effect of having a freshly perturbed training distribution on each iteration is that each decision node represents a sample from the approximate locations of the optimal boundary values. The resulting decision node boundary values are binned with a simple histogram function.