Step 3: Post-processing methodologies for Explainability

Post-processing techniques can be applied to the outputs of an algorithm after training. These techniques are also model-agnostic in that they do not depend on the specific machine learning model used. They can even be used with black-box models like deep neural networks.

These techniques focus on understanding the algorithm’s behavior at a high/dataset/populational level. Here are some global post-processing techniques:

  • Feature Importance. We can usually find that not all the input features are equally relevant to the prediction task. In fact, it is often only a few of them that have substantial predictive power. Features importance metrics help us understand which features are more important for our task, which in turn can make “black-box” models more transparent.

    • Permutation feature importance: One way to estimate feature importance is by measuring how the prediction error of the model changes if we permute the feature’s values (and thus break the relationship between input and output). Intuitively, if shuffling a specific feature leads to a substantial increase in the prediction error, then we can deem that feature important for the task at hand. It can be implemented with sklearn. Feature importance provides a compact, global explanation for the model. It’s a simple measure that can be used to compare different problems, and it automatically takes into account higher-level interactions between features. However, permutation is a random process and as such the results may suffer from high variance. Another downside is that importance may be underestimated in the presence of correlated variables

  • Partial dependence. Partial dependence functions can be used to interpret the results of any “black box” learning method. Partial dependence can show the marginal effect of one or two input features on the outcome. More intuitively, it would explain what happens to the target if I modify one or two input variables. Mathematically, we have that, given a feature set S and its complement C, partial dependence can be estimated by: pd^XS(xS)=1ni=1nF(xS,xC(i))\hat{pd}_{XS}(x_S)= \frac{1}{n} \sum_{i=1}^{n}{F(x_S,x_C^{(i)})} , where xC(i)x_C^{(i)} is the value of the i-th sample for the features in xCx_C and for every value xSx_S in the range. It can be implemented with sklearn. Please note that we are assuming that the features in set S and the features in its complement C are not correlated, breaking this assumption would lead to misleading results. Partial dependence is an intuitive measure that provides a clear explanation that can be interpreted causally, i.e. we can measure the changes in the target variable if we intervene on a feature. The implementation is simple, however, it can involve a heavy amount of computation for most models. Decision trees are an exception to this, in that the partial dependence can be rapidly computed from the tree itself without reference to the data.

You can find an example in our notebook, which can be visualized here or downloaded below:

Last updated