Skip to content
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

Renamed nSII to k-SII and refactors base approximators #42

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,29 @@ You can use `shapiq` in different ways. If you have a trained model you can rely
If you are interested in the underlying game theoretic algorithms, then check out the `shapiq.approximator` modules.
You can also plot and visualize your interaction scores with `shapiq.plot`.

## 📈 Compute n-SII values
## 📈 Compute k-SII values

Explain your models with Shapley interaction values like the n-SII values:
Explain your models with Shapley interaction values like the k-SII values:

```python
# train a model
from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor(n_estimators=50, random_state=42)
model.fit(x_train, y_train)

# explain with nSII interaction scores
# explain with k-SII interaction scores
from shapiq import InteractionExplainer
explainer = InteractionExplainer(
model=model.predict,
background_data=x_train,
index="nSII",
index="k-SII",
max_order=2
)
interaction_values = explainer.explain(x_explain, budget=2000)
print(interaction_values)

>>> InteractionValues(
>>> index=nSII, max_order=2, min_order=1, estimated=True, estimation_budget=2000,
>>> index=k-SII, max_order=2, min_order=1, estimated=True, estimation_budget=2000,
>>> values={
>>> (0,): -91.0403, # main effect for feature 0
>>> (1,): 4.1264, # main effect for feature 1
Expand All @@ -110,8 +110,8 @@ attribution scores and interaction scores, respectively.
from shapiq.plot import network_plot

network_plot(
first_order_values=n_sii_first_order, # first order n-SII values
second_order_values=n_sii_second_order # second order n-SII values
first_order_values=k_sii_first_order, # first order k-SII values
second_order_values=k_sii_second_order # second order k-SII values
)
```

Expand Down
4 changes: 1 addition & 3 deletions shapiq/approximator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""This module contains the approximators to estimate the Shapley interaction values."""
from ._base import convert_nsii_into_one_dimension, transforms_sii_to_nsii # TODO add to tests
from .k_sii import convert_ksii_into_one_dimension, transforms_sii_to_ksii
from .permutation.sii import PermutationSamplingSII
from .permutation.sti import PermutationSamplingSTI
from .regression import RegressionSII, RegressionFSI, KernelSHAP
Expand All @@ -12,6 +12,4 @@
"RegressionFSI",
"RegressionSII",
"ShapIQ",
"transforms_sii_to_nsii",
"convert_nsii_into_one_dimension",
]
Loading
Loading