New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to interpret LIME results? #113
Comments
I think this is a bit confusing because you're using numerical data, but the default parameters in TabularExplainer discretize the data into quartiles. It is harder to interpret explanations for numerical features for the following reasons:
Anyway, let's consider the meaning of the explanations in the discretized version.
Roughly, what I'm doing above is integrating over other values of You could set |
Thanks Marc for the input. It did help. As a follow-up, here are the results of the relative error of LIME with increasing number of samples, where relative error means the explanation with a given number of samples Would you expect the relative error to go to zero? If not, what variables would I need to increase for the error to go to zero? If none, what approximations explain the discrepancy of ~5%? Figure generated with the code below:
Output to stdout:
|
I would not expect the error to go to zero, because the model is using continuous data while LIME is approximating it with the discretized version. Also, there is the locality weighting, i.e. samples near the point being explained are weighted more heavily than samples far away. |
Discretization does make everything tricky. In your code, you're computing the residual with respect to the prediction of the event. However, LIME is taking the event to be a > 0.5 and b > 0.5, not two specific values. So, instead of:
We should have
Also, the value of b for LIME is b > 0.5, so instead of:
let's have:
These two would explain why your error goes up the further you are from a=1, I think.
Doing these results in a relative error that is ~constant with respect to the events (around 10%). |
Thank you @marcotcr for the explanation. That does indeed explain the error above: To summarize: the interpretation of
is
Doesn't this imply that LIME result only depends on the quartile that the events belong to? For example, isn't it possible for LIME to provide the same explanation for two events whose outcome is opposite? (e.g. the model gives a different prediction on different values of the same quartile).
|
Yes, that is possible. That is a problem with discretization, we lose the ability to differentiate things within the discretized bins. Obvious solutions to this involve using more bins (deciles, entropy-based discretization) or not discretizing at all. Not discretizing at all has its own drawbacks, which is why I decided to leave discretization in as the default. |
@marcotcr. I understand. Regardless of this particular point, LIME remains a useful tool for interpretability. Thank you and the other authors for taking the time to develop and publish it, provide source code to reproduce its results, and thank you especially for clarifying the points raised here. Definitely a great example of how science should be done! I will close this as resolved. |
Thanks for the thoughtful questions! |
Ok, I returned to this, now for the non-discretized version. Essentially, trying to do the same for the non-discretized version of LIME. My expectation, based on the results from the discretized version, is that LIME approximates the partial derivative of the function in respect to each input. However, I may be mistaken, because I am getting a 20% systematic error between LIME and the partial derivate.
|
Maybe we should move away from the partial derivative interpretation, and back to the original meaning of an explanation: a linear model that approximates the black box model locally.
We should have that (f - fhat).mean() is small, in particular for x that are close to the original instance. |
It makes sense. The reason I approached it from the partial derivatives is that given a point x' = x + h, |
Let's call f'(x') the gradient of x'. LIME is trying to find w such that (ignoring the local weighting for now): I don't see why Also, I think f'(x) should be |
Hi guys, I hope I'm not hijacking this thread, but it's kind of relevant to interpreting LIME. If I want to print the coefficients that the local LIME model learned, is there a way to do that? Thanks in advance. |
|
I am finding the set of variables list we getting from explainer is keep changing when we re-run the rf_explainer.explain_instance on the same test data, may I please know do we have to set.seed or something, or why the variable importance changes. Thanks |
Hi marcotcr,
Still i am getting different values
Also, I am getting all values as zeros, which I don't understand why, may I have some help please? |
hello |
I am considering using LIME, and I am having some struggle to understand what exactly it outputs.
I posed a question on stack exchange with a MCVE, but maybe this is more suitable here.
Consider the following code, that uses logistic regression to fit a logistic process, and uses LIME for a new example.
output:
the
~[[1, 1]]
is because we are doing logistic regression to a Logistic process with these coefficients.What do the values
0.219...
mean? Are they relatable to any quantity of this example?The text was updated successfully, but these errors were encountered: