Skip to content

Small demo of shap-like feature#90

Merged
JingangQu merged 11 commits intosoda-inria:mainfrom
GaelVaroquaux:demo_shap
Mar 25, 2026
Merged

Small demo of shap-like feature#90
JingangQu merged 11 commits intosoda-inria:mainfrom
GaelVaroquaux:demo_shap

Conversation

@GaelVaroquaux
Copy link
Copy Markdown
Member

Fixes #89 to make shap-like features more easy to discover

Copy link
Copy Markdown
Collaborator

@JingangQu JingangQu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for me!

@marineLM
Copy link
Copy Markdown
Collaborator

marineLM commented Mar 25, 2026

For coherence, I think it would make sense to present it as a separate tutorial rather than include it in the Getting Started page.

@GaelVaroquaux
Copy link
Copy Markdown
Member Author

I think it would make sense to present it as a separate tutorial rather than include it in the Getting Started page.

I can do it if you want.

The benefit would be to make it more visible.

The drawback is that long term a proliferation of small examples crowds a documentation and gives a daunting page of examples. Of course, the solution would be to restructure the documentation when this happen, but experience shows that this does not happen, because it's a lot of work and people are seldom excited about this.

@marineLM : tell me what you want me to do.

@dholzmueller
Copy link
Copy Markdown
Collaborator

What about we make a separate SHAP tutorial (I also thought of doing it this way) but then we also put the other extensions (unsupervised learning) in the same tutorial later on?

@GaelVaroquaux
Copy link
Copy Markdown
Member Author

OK. One thing to keep in mind is that time is limited, and having something is better than having nothing.

I can dedicate another 10 or 20mn to this, not more. The current status is that our shap features are not exposed at all. People won't find it, and right now the conversation on interpretability and TFM is focusing on the packages that expose shap features.

@GaelVaroquaux
Copy link
Copy Markdown
Member Author

OK, I'm making an editorial decision (because I can try and work on this now, and will not later):

The example that I did is a bit crappy in term of interpretability, because the data is synthetic, and the column names don't anything.

I'll try to make an example using the data in https://scikit-learn.org/stable/auto_examples/inspection/plot_linear_model_coefficient_interpretation.html
I'll see if I have time (no promises, I might get interrupted)

@GaelVaroquaux
Copy link
Copy Markdown
Member Author

GaelVaroquaux commented Mar 25, 2026

I have error, related to numba, that I don't fully understand.

Might be legit, @JingangQu

@JingangQu
Copy link
Copy Markdown
Collaborator

JingangQu commented Mar 25, 2026

I have error, related to numba, that I don't fully understand.

Might be legit, @JingangQu

@GaelVaroquaux, I found out the problem. the following code in your example

X = pd.get_dummies(X, drop_first=True)

yields boolean columns with True / False. In the shap file, I've used X_np = np.asarray(X_test) producing an object dtype array. SHAP's masker passes this to a numba @njit function which can't handle object arrays.

I fix this problem via X_np = np.asarray(X_test, dtype=np.float64).

btw, your shap example takes too much time (about 15 minutes on my macbook with m3 pro). We need a lightweight example. I'll do it.

@GaelVaroquaux
Copy link
Copy Markdown
Member Author

Thanks for the fix, @JingangQu . I think that this look great.

IMHO, we should merge. It's very useful, and I want to use it on social media :)

@JingangQu
Copy link
Copy Markdown
Collaborator

JingangQu commented Mar 25, 2026

Thanks for the fix, @JingangQu . I think that this look great.

IMHO, we should merge. It's very useful, and I want to use it on social media :)

Just wait for a moment. There is an issue in the toturial figures. I am fixing it. After that, I will merge it

@JingangQu JingangQu merged commit 02c52ad into soda-inria:main Mar 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demo shap feature in an example

4 participants