Magnus Nielsen, SODAS, UCPH
In your opinion, what is explainability in the context of machine learning?
What is an explanation?
In the context of today:
Today we will look at
Understanding our models can help in many scenarios
Important to remember that explanations are social and should be tailored to the situation
Some other general pointers to think about when explaining your models:
Global and local methods
Global methods describe the average behaviour of a machine learning model
Local methods explain individual predictions (or model in the vicinity of an individual prediction)
The most important property is how comprehensible the explanations are
The social context of explanations is especially important here
There are many other properties that one can consider, i.e.:
A longer list can be seen here
Expressive Power
Translucency
Portability
Algorithmic Complexity
Two methods:
The most accepted within social sciences and legislation are intrinsically interpretable models
This is not always necessary and model-agnostic post-hoc methods are most often used
In linear models, we can interpret the weights
Lots of collective experience
Source: Molnar, 2022
Source: Molnar, 2022
Source: Molnar, 2022
LASSO models create sparse models due to the \(L_2\) norm
Can be done to either
\(\alpha\) can be tuned such that a set amount of weights are non-zero
No interactions unless you include them
Linear models do not perform well with non-linear data
All else equal interpretation
If features covary, model may arbitrarily select one
Decision trees can be plotted
sklearn
Maximum amount of leafs is maximum depth to the power of two
Do you consider linear regression or decision trees to be most explainable?
I wager that most people here would default to linear regression
You would have no problem interpreting coefficients
I posit that decision trees are more easily understood for a layman
Another method for trees, which calculates global feature importance
For all features:
Scale sum of importances to 100
Source: sklearn
This method is generally biased and favors high cardinality features.
Why?
The method favors high cardinality features because these features are more often split on
Can only say something about the model in relation to the training data
As a result, not often used
Some models are so complex that we cannot understand them or their components
Here we can use model agnostic explanation methods
Permute a feature
How much does this loss of information change the score (e.g. MSE)
Can be computed for both train and test
Most commonly done on test data
However, training data will show what features the model uses
Source: sklearn
Pros:
Cons:
What happens when we set a feature \(X\) with \(x\)?
Plot how the average prediction changes as a function of \(X\)
Source: Molnar, 2022
Pros
Cons
How to avoid hiding heterogeneous effects?
Plot a partial dependence for all observations!
As we no longer average over all observations, it is local
Source: Molnar, 2022
Source: Molnar, 2022
Pros
Cons
Shapley Additive Explanations allocate prediction outputs as if a game (Shapley values) using a local interpretable model (LIME)
There’s a lot of math and pseudo-code in the papers and book regarding SHAP and it subcomponents
Local interpretable model-agnostic explanations introduced by Ribeiro et al. (2016)
Create a low-complexity (intrinsically interpretable) model for each observation
Available stand-alone in the package LIME (not covered in exercises)
Select observation to explain
Big question: What kernel bandwidth to use?
Source: Molnar, 2022
Source: Molnar, 2022
Allocate payout using Shapley values from cooperative game theory
Theoretically grounded
Groups of players (coalitions) can either participate in the game or not
This change in payoff is distributed to the players in the coalition
Game is played for each instance
Nice theoretical guarantees
Source: aidancooper.co.uk
Need to calculate models with the power set of all features
This quickly becomes computationally expensive
To reduce compute, we return to SHAP (Lundberg & Lee, 2017)
Essentially: Change kernel in LIME with a weighing scheme based on Shapley values!
Why?
To ‘simulate not participating’, we permute the features
By doing this, we retain an (uninformative) input (which the model requires) and do not need to retrain!
Generally, we sample from a given dataset (subset of the training data or prototypical observations)
This can induce nonsensical feature combinations
Called interventional feature perturbation, and is default in SHAP
There exists an alternative SHAP implementations for tree-based models, introduced in Lundberg et al. (2020)
Here we can do path dependent sampling
Essentially, we use information about how many samples were in each node during training
Source: nicolas-hug.com
True to the model: Interventional
True to the data: Path-dependent
Lets talk plots
We remember that SHAP values are all individual
Through clever plots and summary statistics, we can still obtain global insights
All easy to compute and plot through SHAP
Source: Molnar, 2022
Source: Molnar, 2022
Source: Molnar, 2022
Source: Molnar, 2022
Source: Molnar, 2022
Pros
Cons
The rest of the book by Molnar has more methods
Text and image also have methods developed for them
Janzing, D., Minorics, L., & Blöbaum, P. (2020, June). Feature relevance quantification in explainable AI: A causal problem. In International Conference on artificial intelligence and statistics (pp. 2907-2916). PMLR.
Lundberg, S. M., Erion, G., Chen, H., DeGrave, A., Prutkin, J. M., Nair, B., … & Lee, S. I. (2020). From local explanations to global understanding with explainable AI for trees. Nature machine intelligence, 2(1), 56-67.
Lundberg, S. M., & Lee, S. I. (2017). A unified approach to interpreting model predictions. Advances in neural information processing systems, 30.
Molnar, C. (2022). Interpretable machine learning, https://christophm.github.io/interpretable-ml-book/ (2022-12-14)
Ribeiro, M. T., Singh, S., & Guestrin, C. (2016, August). ” Why should i trust you?” Explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining (pp. 1135-1144).
Slack, D., Hilgard, S., Jia, E., Singh, S., & Lakkaraju, H. (2020, February). Fooling lime and shap: Adversarial attacks on post hoc explanation methods. In Proceedings of the AAAI/ACM Conference on AI, Ethics, and Society (pp. 180-186).