Ex. 10.11
Ex. 10.11
Show how to compute the partial dependence function \(f_{\mathcal{S}}(X_{\mathcal{S}})\) in (10.47) efficiently.
Soln. 10.11
In general, to calculate partial dependence as in (10.47), given a \(x_s\in X_{\mathcal{S}}\), we need to make \(N\) predictions for \(N\) samples \((x_s, x_{i\mathcal{C}}) (i=1,...,N)\) and take an average.
For decision trees, note that each node of the fitted tree remembers how many training samples went through it during the training, and thus we can use associated ratios to derive the final average. That means, we only need to traverse the tree for once. Please see Efficient Partial Dependence Plots with decision trees for a detailed description and scikit-learn's implementation.