shapiq 1.2.2__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shapiq-1.3.0/CHANGELOG.md +130 -0
- {shapiq-1.2.2/shapiq.egg-info → shapiq-1.3.0}/PKG-INFO +110 -74
- {shapiq-1.2.2 → shapiq-1.3.0}/README.md +35 -4
- shapiq-1.3.0/pyproject.toml +245 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/__init__.py +16 -3
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/__init__.py +23 -4
- shapiq-1.2.2/shapiq/approximator/_base.py → shapiq-1.3.0/shapiq/approximator/base.py +161 -149
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/marginals/owen.py +84 -26
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/marginals/stratified.py +52 -15
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/montecarlo/__init__.py +1 -1
- shapiq-1.2.2/shapiq/approximator/montecarlo/_base.py → shapiq-1.3.0/shapiq/approximator/montecarlo/base.py +133 -65
- shapiq-1.3.0/shapiq/approximator/montecarlo/shapiq.py +165 -0
- shapiq-1.3.0/shapiq/approximator/montecarlo/svarmiq.py +124 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/permutation/sii.py +62 -20
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/permutation/stii.py +111 -35
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/permutation/sv.py +72 -12
- shapiq-1.3.0/shapiq/approximator/regression/__init__.py +17 -0
- shapiq-1.2.2/shapiq/approximator/regression/_base.py → shapiq-1.3.0/shapiq/approximator/regression/base.py +278 -185
- shapiq-1.3.0/shapiq/approximator/regression/faithful.py +134 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/regression/kadd_shap.py +34 -15
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/regression/kernelshap.py +33 -15
- shapiq-1.3.0/shapiq/approximator/regression/kernelshapiq.py +157 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/sampling.py +133 -59
- shapiq-1.3.0/shapiq/approximator/sparse/__init__.py +9 -0
- shapiq-1.3.0/shapiq/approximator/sparse/base.py +303 -0
- shapiq-1.3.0/shapiq/approximator/sparse/spex.py +67 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/configuration.py +29 -37
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/load.py +42 -35
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/metrics.py +29 -18
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/plot.py +41 -31
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/precompute.py +44 -51
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/benchmark/run.py +76 -61
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/datasets/_all.py +31 -22
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/__init__.py +3 -2
- shapiq-1.3.0/shapiq/explainer/agnostic.py +131 -0
- shapiq-1.3.0/shapiq/explainer/base.py +265 -0
- shapiq-1.3.0/shapiq/explainer/configuration.py +189 -0
- shapiq-1.3.0/shapiq/explainer/custom_types.py +7 -0
- shapiq-1.3.0/shapiq/explainer/tabpfn.py +159 -0
- shapiq-1.3.0/shapiq/explainer/tabular.py +209 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/base.py +46 -22
- shapiq-1.3.0/shapiq/explainer/tree/conversion/__init__.py +1 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/conversion/edges.py +39 -25
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/conversion/lightgbm.py +15 -14
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/conversion/sklearn.py +36 -18
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/conversion/xgboost.py +22 -17
- shapiq-1.3.0/shapiq/explainer/tree/explainer.py +152 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/treeshapiq.py +232 -117
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/utils.py +7 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/validation.py +23 -10
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/utils.py +103 -43
- shapiq-1.3.0/shapiq/explainer/validation.py +137 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/__init__.py +6 -4
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/aggregation.py +28 -20
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/core.py +26 -12
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/exact.py +316 -185
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/indices.py +58 -30
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/game_theory/moebius_converter.py +186 -126
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/__init__.py +0 -3
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/base.py +157 -73
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/__init__.py +48 -32
- shapiq-1.3.0/shapiq/games/benchmark/_setup/__init__.py +7 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/_setup/_california_torch_setup.py +30 -16
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/_setup/_resnet_setup.py +24 -15
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/_setup/_vit_setup.py +36 -24
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/data_valuation/__init__.py +0 -2
- shapiq-1.3.0/shapiq/games/benchmark/data_valuation/base.py +124 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/data_valuation/benchmark.py +48 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/dataset_valuation/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/dataset_valuation/base.py +65 -33
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/dataset_valuation/benchmark.py +68 -30
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/ensemble_selection/__init__.py +7 -7
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/ensemble_selection/base.py +116 -58
- shapiq-1.3.0/shapiq/games/benchmark/ensemble_selection/benchmark.py +201 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/ensemble_selection/benchmark_random_forest.py +68 -36
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/feature_selection/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/feature_selection/base.py +55 -31
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/feature_selection/benchmark.py +52 -32
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/global_xai/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/global_xai/base.py +45 -23
- shapiq-1.3.0/shapiq/games/benchmark/global_xai/benchmark_tabular.py +194 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/local_xai/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/local_xai/base.py +41 -23
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/local_xai/benchmark_image.py +70 -32
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/local_xai/benchmark_language.py +34 -28
- shapiq-1.3.0/shapiq/games/benchmark/local_xai/benchmark_tabular.py +213 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/setup.py +66 -41
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/synthetic/__init__.py +2 -3
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/synthetic/dummy.py +20 -13
- shapiq-1.3.0/shapiq/games/benchmark/synthetic/random_game.py +46 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/synthetic/soum.py +93 -44
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/treeshapiq_xai/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/treeshapiq_xai/base.py +67 -33
- shapiq-1.3.0/shapiq/games/benchmark/treeshapiq_xai/benchmark.py +270 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/uncertainty/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/uncertainty/base.py +60 -11
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/uncertainty/benchmark.py +33 -7
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/unsupervised_cluster/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/unsupervised_cluster/base.py +49 -18
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/unsupervised_cluster/benchmark.py +55 -24
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/unsupervised_data/__init__.py +0 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/benchmark/unsupervised_data/base.py +31 -15
- shapiq-1.3.0/shapiq/games/benchmark/unsupervised_data/benchmark.py +76 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/base.py +56 -28
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/baseline_imputer.py +48 -21
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/conditional_imputer.py +76 -37
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/marginal_imputer.py +56 -36
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/tabpfn_imputer.py +61 -29
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/interaction_values.py +268 -128
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/__init__.py +1 -1
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/_config.py +4 -1
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/bar.py +13 -2
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/force.py +88 -50
- shapiq-1.3.0/shapiq/plot/network.py +70 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/sentence.py +15 -8
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/si_graph.py +486 -242
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/stacked_bar.py +21 -16
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/upset.py +25 -9
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/plot/utils.py +62 -8
- shapiq-1.2.2/shapiq/plot/watefall.py → shapiq-1.3.0/shapiq/plot/waterfall.py +54 -21
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/utils/__init__.py +3 -1
- shapiq-1.3.0/shapiq/utils/custom_types.py +30 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/utils/datasets.py +6 -1
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/utils/modules.py +29 -26
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/utils/sets.py +67 -23
- {shapiq-1.2.2 → shapiq-1.3.0/shapiq.egg-info}/PKG-INFO +110 -74
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq.egg-info/SOURCES.txt +16 -15
- shapiq-1.3.0/shapiq.egg-info/requires.txt +26 -0
- shapiq-1.2.2/CHANGELOG.md +0 -87
- shapiq-1.2.2/MANIFEST.in +0 -3
- shapiq-1.2.2/pyproject.toml +0 -16
- shapiq-1.2.2/setup.py +0 -110
- shapiq-1.2.2/shapiq/approximator/montecarlo/shapiq.py +0 -130
- shapiq-1.2.2/shapiq/approximator/montecarlo/svarmiq.py +0 -89
- shapiq-1.2.2/shapiq/approximator/regression/__init__.py +0 -8
- shapiq-1.2.2/shapiq/approximator/regression/fsi.py +0 -51
- shapiq-1.2.2/shapiq/approximator/regression/kernelshapiq.py +0 -132
- shapiq-1.2.2/shapiq/explainer/_base.py +0 -155
- shapiq-1.2.2/shapiq/explainer/tabpfn.py +0 -129
- shapiq-1.2.2/shapiq/explainer/tabular.py +0 -278
- shapiq-1.2.2/shapiq/explainer/tree/conversion/__init__.py +0 -0
- shapiq-1.2.2/shapiq/explainer/tree/explainer.py +0 -115
- shapiq-1.2.2/shapiq/games/benchmark/_setup/__init__.py +0 -4
- shapiq-1.2.2/shapiq/games/benchmark/data_valuation/base.py +0 -92
- shapiq-1.2.2/shapiq/games/benchmark/ensemble_selection/benchmark.py +0 -166
- shapiq-1.2.2/shapiq/games/benchmark/global_xai/benchmark_tabular.py +0 -157
- shapiq-1.2.2/shapiq/games/benchmark/local_xai/benchmark_tabular.py +0 -171
- shapiq-1.2.2/shapiq/games/benchmark/treeshapiq_xai/benchmark.py +0 -216
- shapiq-1.2.2/shapiq/games/benchmark/unsupervised_data/benchmark.py +0 -37
- shapiq-1.2.2/shapiq/plot/network.py +0 -382
- shapiq-1.2.2/shapiq/utils/types.py +0 -6
- shapiq-1.2.2/shapiq.egg-info/requires.txt +0 -53
- shapiq-1.2.2/shapiq.egg-info/zip-safe +0 -1
- shapiq-1.2.2/tests/test_abstract_classes.py +0 -64
- shapiq-1.2.2/tests/test_base_interaction_values.py +0 -763
- shapiq-1.2.2/tests/test_configuration.py +0 -17
- shapiq-1.2.2/tests/test_integration_import_all.py +0 -60
- {shapiq-1.2.2 → shapiq-1.3.0}/LICENSE +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/setup.cfg +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/marginals/__init__.py +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/approximator/permutation/__init__.py +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/datasets/__init__.py +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/explainer/tree/__init__.py +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq/games/imputer/__init__.py +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq.egg-info/dependency_links.txt +0 -0
- {shapiq-1.2.2 → shapiq-1.3.0}/shapiq.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
## Changelog
|
|
2
|
+
|
|
3
|
+
### v1.3.0 (2025-06-17)
|
|
4
|
+
|
|
5
|
+
#### Highlights
|
|
6
|
+
- `shapiq.SPEX` (Sparse Exact) approximator for efficient computation of sparse interaction values for really large models and games. Paper: [SPEX: Scaling Feature Interaction Explanations for LLMs](https://arxiv.org/abs/2502.13870)
|
|
7
|
+
- `shapiq.AgnosticExplainer` a generic explainer that works for any value function or `shapiq.Game` object, allowing for more flexibility in explainers.
|
|
8
|
+
- prettier graph-based plots via `shapiq.si_graph_plot()` and `shapiq.network_plot()`, which now use the same backend for more flexibility and easier maintenance.
|
|
9
|
+
|
|
10
|
+
#### New Features
|
|
11
|
+
- adds the SPEX (Sparse Exact) module in `approximator.sparse` for efficient computation of sparse interaction values [#379](https://github.com/mmschlk/shapiq/pull/379)
|
|
12
|
+
- adds `shapiq.AgnosticExplainer` which is a generic explainer that can be used for any value function or `shapiq.Game` object. This allows for more flexibility in the explainers. [#100](https://github.com/mmschlk/shapiq/issues/100), [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
13
|
+
- changes `budget` to be a mandatory parameter given to the `TabularExplainer.explain()` method [#355](https://github.com/mmschlk/shapiq/pull/356)
|
|
14
|
+
- changes logic of `InteractionValues.get_n_order()` function to be callable with **either** the `order: int` parameter and optional assignment of `min_order: int` and `max_order: int` parameters **or** with the min/max order parameters [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
15
|
+
- renamed `min_percentage` parameter in the force plot to `contribution_threshold` to better reflect its purpose [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
16
|
+
- adds ``verbose`` parameter to the ``Explainer``'s ``explain_X()`` method to control weather a progress bar is shown or not which is defaulted to ``False``. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
17
|
+
- made `InteractionValues.get_n_order()` and `InteractionValues.get_n_order_values()` function more efficient by iterating over the stored interactions and not over the powerset of all potential interactions, which made the function not usable for higher player counts (models with many features, and results obtained from `TreeExplainer`). Note, this change does not really help `get_n_order_values()` as it still needs to create a numpy array of shape `n_players` times `order` [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
18
|
+
- streamlined the ``network_plot()`` plot function to use the ``si_graph_plot()`` as its backend function. This allows for more flexibility in the plot function and makes it easier to use the same code for different purposes. In addition, the ``si_graph_plot`` was modified to make plotting more easy and allow for more flexibility with new parameters. [#349](https://github.com/mmschlk/shapiq/pull/349)
|
|
19
|
+
- adds `Game.compute()` method to the `shapiq.Game` class to compute game values without changing the state of the game object. The compute method also introduces a `shapiq.utils.sets.generate_interaction_lookup_from_coalitions()` utility method which creates an interaction lookup dict from an array of coalitions. [#397](https://github.com/mmschlk/shapiq/pull/397)
|
|
20
|
+
- streamlines the creation of network plots and graph plots which now uses the same backend. The network plot via `shapiq.network_plot()` or `InteractionValues.plot_network()` is now a special case of the `shapiq.si_graph_plot()` and `InteractionValues.plot_si_graph()`. This allows to create more beautiful plots and easier maintenance in the future. [#349](https://github.com/mmschlk/shapiq/pull/349)
|
|
21
|
+
|
|
22
|
+
#### Testing, Code-Quality and Documentation
|
|
23
|
+
- activates ``"ALL"`` rules in ``ruff-format`` configuration to enforce stricter code quality checks and addressed around 500 (not automatically solvable) issues in the code base. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
24
|
+
- improved the testing environment by adding a new fixture module containing mock `InteractionValues` objects to be used in the tests. This allows for more efficient and cleaner tests, as well as easier debugging of the tests [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
25
|
+
- removed check and error message if the ``index`` parameter is not in the list of available indices in the ``TabularExplainer`` since the type hints were replaced by Literals [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
26
|
+
- removed multiple instances where ``shapiq`` tests if some approximators/explainers can be instantiated with certain indices or not in favor of using Literals in the ``__init__`` method of the approximator classes. This allows for better type hinting and IDE support, as well as cleaner code. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
27
|
+
- Added documentation for all public modules, classes, and functions in the code base to improve the documentation quality and make it easier to understand how to use the package. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
28
|
+
- suppress a ``RuntimeWarning`` in ``Regression`` approximators ``solve_regression()``method when the solver is not able to find good interim solutions for the regression problem.
|
|
29
|
+
- refactors the tests into ``tests_unit/`` and ``tests_integration/`` to better separate unit tests from integration tests. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
30
|
+
- adds new integration tests in ``tests/tests_integration/test_explainer_california_housing`` which compares the different explainers against ground-truth interaction values computed by ``shapiq.ExactComputer`` and interaction values stored on [disk](https://github.com/mmschlk/shapiq/tree/main/tests/data/interaction_values/california_housing) as a form of regression test. This test should help finding bugs in the future when the approximators, explainers, or exact computation are changed. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
31
|
+
|
|
32
|
+
#### Bug Fixes
|
|
33
|
+
- fixed a bug in the `shapiq.waterfall_plot` function that caused the plot to not display correctly resulting in cutoff y_ticks. Additionally, the file was renamed from `watefall.py` to `waterfall.py` to match the function name [#377](https://github.com/mmschlk/shapiq/pull/377)
|
|
34
|
+
- fixes a bug with `TabPFNExplainer`, where the model was not able to be used for predictions after it was explained. This was due to the model being fitted on a subset of features, which caused inconsistencies in the model's predictions after explanation. The fix includes that after each call to the `TabPFNImputer.value_function`, the tabpfn model is fitted on the whole dataset (without omitting features). This means that the original model can be used for predictions after it has been explained. [#396](https://github.com/mmschlk/shapiq/issues/396).
|
|
35
|
+
- fixed a bug in computing `BII` or `BV` indices with `shapiq.approximator.MonteCarlo` approximators (affecting `SHAP-IQ`, `SVARM` and `SVARM-IQ`). All orders of BII should now be computed correctly. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
36
|
+
|
|
37
|
+
### v1.2.3 (2025-03-24)
|
|
38
|
+
- substantially improves the runtime of all `Regression` approximators by a) a faster pre-computation of the regression matrices and b) a faster computation of the weighted least squares regression [#340](https://github.com/mmschlk/shapiq/issues/340)
|
|
39
|
+
- removes `sample_replacements` parameter from `MarginalImputer` and removes the DeprecationWarning for it
|
|
40
|
+
- adds a trivial computation to `TreeSHAP-IQ` for trees that use only one feature in the tree (this works for decision stumps or trees splitting on only one feature multiple times). In such trees, the computation is trivial as the whole effect of $\nu(N) - \nu(\emptyset)$ is all on the main effect of the single feature and there is no interaction effect. This expands on the fix in v1.2.1 [#286](https://github.com/mmschlk/shapiq/issues/286).
|
|
41
|
+
- fixes a bug with xgboost where feature names where trees that did not contain all features would lead `TreeExplainer` to fail
|
|
42
|
+
- fixes a bug with `stacked_bar_plot` where the higher order interactions were inflated by the lower order interactions, thus wrongly showing the higher order interactions as higher than they are
|
|
43
|
+
- fixes a bug where `InteractionValues.get_subset()` returns a faulty `coalition_lookup` dictionary pointing to indices outside the subset of players [#336](https://github.com/mmschlk/shapiq/issues/336)
|
|
44
|
+
- updates default value of `TreeExplainer`'s `min_order` parameter from 1 to 0 to include the baseline value in the interaction values as per default
|
|
45
|
+
- adds the `RegressionFBII` approximator to estimate Faithful Banzhaf interactions via least squares regression [#333](https://github.com/mmschlk/shapiq/pull/333). Additionally, FBII support was introduced in TabularExplainer and MonteCarlo-Approximator.
|
|
46
|
+
- adds a `RandomGame` class as part of `shapiq.games.benchmark` which always returns a random vector of integers between 0 and 100.
|
|
47
|
+
|
|
48
|
+
### v1.2.2 (2025-03-11)
|
|
49
|
+
- changes python support to 3.10-3.13 [#318](https://github.com/mmschlk/shapiq/pull/318)
|
|
50
|
+
- fixes a bug that prohibited importing shapiq in environments without write access [#326](https://github.com/mmschlk/shapiq/issues/326)
|
|
51
|
+
- adds `ExtraTreeRegressors` to supported models [#309](https://github.com/mmschlk/shapiq/pull/309)
|
|
52
|
+
|
|
53
|
+
### v1.2.1 (2025-02-17)
|
|
54
|
+
- fixes bugs regarding plotting [#315](https://github.com/mmschlk/shapiq/issues/315) and [#316](https://github.com/mmschlk/shapiq/issues/316)
|
|
55
|
+
- fixes a bug with TreeExplainer and Trees that consist of only one feature [#286](https://github.com/mmschlk/shapiq/issues/286)
|
|
56
|
+
- fixes SV init with explainer for permutation, svarm, kernelshap, and unbiased kernelshap [#319](https://github.com/mmschlk/shapiq/issues/319)
|
|
57
|
+
- adds a progress bar to `explain_X()` [#324](https://github.com/mmschlk/shapiq/issues/324)
|
|
58
|
+
|
|
59
|
+
### v1.2.0 (2025-01-15)
|
|
60
|
+
- adds ``shapiq.TabPFNExplainer`` as a specialized version of the ``shapiq.TabularExplainer`` which offers a streamlined variant of the explainer for the TabPFN model [#301](https://github.com/mmschlk/shapiq/issues/301)
|
|
61
|
+
- handles ``explainer.explain()`` now through a common interface for all explainer classes which now need to implement a ``explain_function()`` method
|
|
62
|
+
- adds the baseline_value into the InteractionValues object's value storage for the ``()`` interaction if ``min_order=0`` (default usually) for all indices that are not ``SII```(SII has another baseline value) such that the values are efficient (sum up to the model prediction) without the awkward handling of the baseline_value attribute
|
|
63
|
+
- renames ``game_fun`` parameter in ``shapiq.ExactComputer`` to ``game`` [#297](https://github.com/mmschlk/shapiq/issues/297)
|
|
64
|
+
- adds a TabPFN example notebook to the documentation
|
|
65
|
+
- removes warning when class_index is not provided in explainers [#298](https://github.com/mmschlk/shapiq/issues/298)
|
|
66
|
+
- adds the `sentence_plot` function to the `plot` module to visualize the contributions of words to a language model prediction in a sentence-like format
|
|
67
|
+
- makes abbreviations in the `plot` module optional [#281](https://github.com/mmschlk/shapiq/issues/281)
|
|
68
|
+
- adds the `upset_plot` function to the `plot` module to visualize the interactions of higher-order [#290](https://github.com/mmschlk/shapiq/issues/290)
|
|
69
|
+
- adds support for IsoForest models to explainer and tree explainer [#278](https://github.com/mmschlk/shapiq/issues/278)
|
|
70
|
+
- adds support for sub-selection of players in the interaction values data class [#276](https://github.com/mmschlk/shapiq/issues/276) which allows retrieving interaction values for a subset of players
|
|
71
|
+
- refactors game theory computations like `ExactComputer`, `MoebiusConverter`, `core`, among others to be more modular and flexible into the `game_theory` module [#258](https://github.com/mmschlk/shapiq/issues/258)
|
|
72
|
+
- improves quality of the tests by adding many more semantic tests to the different interaction indices and computations [#285](https://github.com/mmschlk/shapiq/pull/285)
|
|
73
|
+
|
|
74
|
+
### v1.1.1 (2024-11-13)
|
|
75
|
+
|
|
76
|
+
#### Improvements and Ease of Use
|
|
77
|
+
- adds a `class_index` parameter to `TabularExplainer` and `Explainer` to specify the class index to be explained for classification models [#271](https://github.com/mmschlk/shapiq/issues/271) (renames `class_label` parameter in TreeExplainer to `class_index`)
|
|
78
|
+
- adds support for `PyTorch` models to `Explainer` [#272](https://github.com/mmschlk/shapiq/issues/272)
|
|
79
|
+
- adds new tests comparing `shapiq` outputs for SVs with alues computed with `shap`
|
|
80
|
+
- adds new tests for checking `shapiq` explainers with different types of models
|
|
81
|
+
|
|
82
|
+
#### Bug Fixes
|
|
83
|
+
- fixes a bug that `RandomForestClassifier` models were not working with the `TreeExplainer` [#273](https://github.com/mmschlk/shapiq/issues/273)
|
|
84
|
+
|
|
85
|
+
### v1.1.0 (2024-11-07)
|
|
86
|
+
|
|
87
|
+
#### New Features and Improvements
|
|
88
|
+
- adds computation of the Egalitarian Core (`EC`) and Egalitarian Least-Core (`ELC`) to the `ExactComputer` [#182](https://github.com/mmschlk/shapiq/issues/182)
|
|
89
|
+
- adds `waterfall_plot` [#34](https://github.com/mmschlk/shapiq/issues/34) that visualizes the contributions of features to the model prediction
|
|
90
|
+
- adds `BaselineImputer` [#107](https://github.com/mmschlk/shapiq/issues/107) which is now responsible for handling the `sample_replacements` parameter. Added a DeprecationWarning for the parameter in `MarginalImputer`, which will be removed in the next release.
|
|
91
|
+
- adds `joint_marginal_distribution` parameter to `MarginalImputer` with default value `True` [#261](https://github.com/mmschlk/shapiq/issues/261)
|
|
92
|
+
- renames explanation graph to `si_graph`
|
|
93
|
+
- `get_n_order` now has optional lower/upper limits for the order
|
|
94
|
+
- computing metrics for benchmarking now tries to resolve not-matching interaction indices and will throw a warning instead of a ValueError [#179](https://github.com/mmschlk/shapiq/issues/179)
|
|
95
|
+
- add a legend to benchmark plots [#170](https://github.com/mmschlk/shapiq/issues/170)
|
|
96
|
+
- refactored the `shapiq.games.benchmark` module into a separate `shapiq.benchmark` module by moving all but the benchmark games into the new module. This closes [#169](https://github.com/mmschlk/shapiq/issues/169) and makes benchmarking more flexible and convenient.
|
|
97
|
+
- a `shapiq.Game` can now be called more intuitively with coalitions data types (tuples of int or str) and also allows to add `player_names` to the game at initialization [#183](https://github.com/mmschlk/shapiq/issues/183)
|
|
98
|
+
- improve tests across the package
|
|
99
|
+
|
|
100
|
+
#### Documentation
|
|
101
|
+
- adds a notebook showing how to use custom tree models with the `TreeExplainer` [#66](https://github.com/mmschlk/shapiq/issues/66)
|
|
102
|
+
- adds a notebook show how to use the `shapiq.Game` API to create custom games [#184](https://github.com/mmschlk/shapiq/issues/184)
|
|
103
|
+
- adds a notebook showing hot to visualize interactions [#252](https://github.com/mmschlk/shapiq/issues/252)
|
|
104
|
+
- adds a notebook showing how to compute Shapley values with `shapiq` [#193](https://github.com/mmschlk/shapiq/issues/197)
|
|
105
|
+
- adds a notebook for conducting data valuation [#190](https://github.com/mmschlk/shapiq/issues/190)
|
|
106
|
+
- adds a notebook showcasing introducing the Core and how to compute it with `shapiq` [#191](https://github.com/mmschlk/shapiq/issues/191)
|
|
107
|
+
|
|
108
|
+
#### Bug Fixes
|
|
109
|
+
- fixes a bug with SIs not adding up to the model prediction because of wrong values in the empty set [#264](https://github.com/mmschlk/shapiq/issues/264)
|
|
110
|
+
- fixes a bug that `TreeExplainer` did not have the correct baseline_value when using XGBoost models [#250](https://github.com/mmschlk/shapiq/issues/250)
|
|
111
|
+
- fixes the force plot not showing and its baseline value
|
|
112
|
+
|
|
113
|
+
### v1.0.1 (2024-06-05)
|
|
114
|
+
|
|
115
|
+
- add `max_order=1` to `TabularExplainer` and `TreeExplainer`
|
|
116
|
+
- fix `TreeExplainer.explain_X(..., n_jobs=2, random_state=0)`
|
|
117
|
+
|
|
118
|
+
### v1.0.0 (2024-06-04)
|
|
119
|
+
|
|
120
|
+
Major release of the `shapiq` Python package including (among others):
|
|
121
|
+
|
|
122
|
+
- `approximator` module implements over 10 approximators of Shapley values and interaction indices.
|
|
123
|
+
- `exact` module implements a computer for over 10 game theoretic concepts like interaction indices or generalized values.
|
|
124
|
+
- `games` module implements over 10 application benchmarks for the approximators.
|
|
125
|
+
- `explainer` module includes a `TabularExplainer` and `TreeExplainer` for any-order feature interactions of machine learning model predictions.
|
|
126
|
+
- `interaction_values` module implements a data class to store and analyze interaction values.
|
|
127
|
+
- `plot` module allows visualizing interaction values.
|
|
128
|
+
- `datasets` module loads datasets for testing and examples.
|
|
129
|
+
|
|
130
|
+
Documentation of `shapiq` with tutorials and API reference is available at https://shapiq.readthedocs.io
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: shapiq
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Shapley Interactions for Machine Learning
|
|
5
|
-
|
|
6
|
-
Author: Maximilian Muschalik
|
|
7
|
-
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL:
|
|
10
|
-
Project-URL:
|
|
11
|
-
Project-URL:
|
|
5
|
+
Author: Hubert Baniecki, Fabian Fumagalli
|
|
6
|
+
Author-email: Maximilian Muschalik <Maximilian.Muschalik@lmu.de>
|
|
7
|
+
Maintainer-email: Maximilian Muschalik <Maximilian.Muschalik@lmu.de>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Project-URL: documentation, https://shapiq.readthedocs.io
|
|
10
|
+
Project-URL: source, https://github.com/mmschlk/shapiq
|
|
11
|
+
Project-URL: tracker, https://github.com/mmschlk/shapiq/issues
|
|
12
|
+
Project-URL: changelog, https://github.com/mmschlk/shapiq/blob/main/CHANGELOG.md
|
|
12
13
|
Keywords: python,machine learning,interpretable machine learning,shap,xai,explainable ai,interaction,shapley interactions,shapley values,feature interaction
|
|
13
14
|
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
15
|
Classifier: Intended Audience :: Developers
|
|
16
16
|
Classifier: Intended Audience :: Science/Research
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering
|
|
18
18
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
-
Classifier:
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Classifier: Operating System :: Unix
|
|
21
|
+
Classifier: Operating System :: MacOS
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
23
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
26
|
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
-
Requires-Python: >=3.10
|
|
27
|
+
Requires-Python: >=3.10
|
|
25
28
|
Description-Content-Type: text/markdown
|
|
26
29
|
License-File: LICENSE
|
|
27
30
|
Requires-Dist: numpy
|
|
@@ -30,64 +33,24 @@ Requires-Dist: pandas
|
|
|
30
33
|
Requires-Dist: scikit-learn
|
|
31
34
|
Requires-Dist: tqdm
|
|
32
35
|
Requires-Dist: requests
|
|
36
|
+
Requires-Dist: sparse-transform
|
|
37
|
+
Requires-Dist: galois
|
|
33
38
|
Requires-Dist: matplotlib
|
|
34
|
-
Requires-Dist: colour
|
|
35
39
|
Requires-Dist: networkx
|
|
36
|
-
|
|
37
|
-
Requires-Dist:
|
|
38
|
-
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist:
|
|
42
|
-
Requires-Dist:
|
|
43
|
-
Requires-Dist:
|
|
44
|
-
Requires-Dist:
|
|
45
|
-
Requires-Dist:
|
|
46
|
-
Requires-Dist:
|
|
47
|
-
Requires-Dist:
|
|
48
|
-
Requires-Dist:
|
|
49
|
-
|
|
50
|
-
Requires-Dist: nbsphinx; extra == "docs"
|
|
51
|
-
Requires-Dist: pandoc; extra == "docs"
|
|
52
|
-
Requires-Dist: furo; extra == "docs"
|
|
53
|
-
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
54
|
-
Requires-Dist: myst-parser; extra == "docs"
|
|
55
|
-
Provides-Extra: dev
|
|
56
|
-
Requires-Dist: numpy; extra == "dev"
|
|
57
|
-
Requires-Dist: scipy; extra == "dev"
|
|
58
|
-
Requires-Dist: pandas; extra == "dev"
|
|
59
|
-
Requires-Dist: scikit-learn; extra == "dev"
|
|
60
|
-
Requires-Dist: tqdm; extra == "dev"
|
|
61
|
-
Requires-Dist: requests; extra == "dev"
|
|
62
|
-
Requires-Dist: matplotlib; extra == "dev"
|
|
63
|
-
Requires-Dist: colour; extra == "dev"
|
|
64
|
-
Requires-Dist: networkx; extra == "dev"
|
|
65
|
-
Requires-Dist: sphinx; extra == "dev"
|
|
66
|
-
Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
|
|
67
|
-
Requires-Dist: sphinx_rtd_theme; extra == "dev"
|
|
68
|
-
Requires-Dist: sphinx_toolbox; extra == "dev"
|
|
69
|
-
Requires-Dist: nbsphinx; extra == "dev"
|
|
70
|
-
Requires-Dist: pandoc; extra == "dev"
|
|
71
|
-
Requires-Dist: furo; extra == "dev"
|
|
72
|
-
Requires-Dist: sphinx-copybutton; extra == "dev"
|
|
73
|
-
Requires-Dist: myst-parser; extra == "dev"
|
|
74
|
-
Requires-Dist: build; extra == "dev"
|
|
75
|
-
Requires-Dist: black; extra == "dev"
|
|
76
|
-
Requires-Dist: pytest; extra == "dev"
|
|
77
|
-
Requires-Dist: coverage; extra == "dev"
|
|
78
|
-
Dynamic: author
|
|
79
|
-
Dynamic: author-email
|
|
80
|
-
Dynamic: classifier
|
|
81
|
-
Dynamic: description
|
|
82
|
-
Dynamic: description-content-type
|
|
83
|
-
Dynamic: home-page
|
|
84
|
-
Dynamic: keywords
|
|
85
|
-
Dynamic: license
|
|
86
|
-
Dynamic: project-url
|
|
87
|
-
Dynamic: provides-extra
|
|
88
|
-
Dynamic: requires-dist
|
|
89
|
-
Dynamic: requires-python
|
|
90
|
-
Dynamic: summary
|
|
40
|
+
Requires-Dist: colour
|
|
41
|
+
Requires-Dist: pillow
|
|
42
|
+
Provides-Extra: ml
|
|
43
|
+
Requires-Dist: tabpfn; extra == "ml"
|
|
44
|
+
Requires-Dist: torchvision; extra == "ml"
|
|
45
|
+
Requires-Dist: torch; extra == "ml"
|
|
46
|
+
Requires-Dist: xgboost; extra == "ml"
|
|
47
|
+
Requires-Dist: lightgbm; extra == "ml"
|
|
48
|
+
Requires-Dist: transformers; extra == "ml"
|
|
49
|
+
Requires-Dist: scikit-image; extra == "ml"
|
|
50
|
+
Requires-Dist: joblib; extra == "ml"
|
|
51
|
+
Requires-Dist: tensorflow; python_version < "3.13" and extra == "ml"
|
|
52
|
+
Requires-Dist: tf-keras; python_version < "3.13" and extra == "ml"
|
|
53
|
+
Dynamic: license-file
|
|
91
54
|
|
|
92
55
|
# shapiq: Shapley Interactions for Machine Learning <img src="https://raw.githubusercontent.com/mmschlk/shapiq/main/docs/source/_static/logo/logo_shapiq_light.svg" alt="shapiq_logo" align="right" height="250px"/>
|
|
93
56
|
|
|
@@ -102,13 +65,21 @@ Dynamic: summary
|
|
|
102
65
|
[](https://pepy.tech/project/shapiq)
|
|
103
66
|
|
|
104
67
|
[](https://github.com/psf/black)
|
|
68
|
+
[](https://github.com/mmschlk/shapiq/issues)
|
|
69
|
+
[](https://github.com/mmschlk/shapiq/commits/main)
|
|
105
70
|
|
|
106
71
|
> An interaction may speak more than a thousand main effects.
|
|
107
72
|
|
|
108
73
|
Shapley Interaction Quantification (`shapiq`) is a Python package for (1) approximating any-order Shapley interactions, (2) benchmarking game-theoretical algorithms for machine learning, (3) explaining feature interactions of model predictions. `shapiq` extends the well-known [shap](https://github.com/shap/shap) package for both researchers working on game theory in machine learning, as well as the end-users explaining models. SHAP-IQ extends individual Shapley values by quantifying the **synergy** effect between entities (aka **players** in the jargon of game theory) like explanatory features, data points, or weak learners in ensemble models. Synergies between players give a more comprehensive view of machine learning models.
|
|
109
74
|
|
|
110
75
|
## 🛠️ Install
|
|
111
|
-
`shapiq` is intended to work with **Python 3.10 and above**.
|
|
76
|
+
`shapiq` is intended to work with **Python 3.10 and above**.
|
|
77
|
+
Installation can be done via `uv` :
|
|
78
|
+
```sh
|
|
79
|
+
uv add shapiq
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
or via `pip`:
|
|
112
83
|
|
|
113
84
|
```sh
|
|
114
85
|
pip install shapiq
|
|
@@ -122,6 +93,7 @@ If you are interested in the underlying game theoretic algorithms, then check ou
|
|
|
122
93
|
### Compute any-order feature interactions
|
|
123
94
|
|
|
124
95
|
Explain your models with Shapley interactions:
|
|
96
|
+
Just load your data and model, and then use a `shapiq.Explainer` to compute Shapley interactions.
|
|
125
97
|
|
|
126
98
|
```python
|
|
127
99
|
import shapiq
|
|
@@ -220,7 +192,7 @@ The pseudo-code above can produce the following plot (here also an image is adde
|
|
|
220
192
|
|
|
221
193
|
### Explain TabPFN
|
|
222
194
|
|
|
223
|
-
With ``shapiq`` you can also [``TabPFN``](https://github.com/PriorLabs/TabPFN) by making use of the _remove-and-recontextualize_ explanation paradigm implemented in ``shapiq.TabPFNExplainer``.
|
|
195
|
+
With ``shapiq`` you can also explain [``TabPFN``](https://github.com/PriorLabs/TabPFN) by making use of the _remove-and-recontextualize_ explanation paradigm implemented in ``shapiq.TabPFNExplainer``.
|
|
224
196
|
|
|
225
197
|
```python
|
|
226
198
|
import tabpfn, shapiq
|
|
@@ -233,7 +205,7 @@ explainer = shapiq.TabPFNExplainer( # setup the explainer
|
|
|
233
205
|
labels=labels,
|
|
234
206
|
index="FSII"
|
|
235
207
|
)
|
|
236
|
-
fsii_values = explainer.explain(
|
|
208
|
+
fsii_values = explainer.explain(data[0]) # explain with Faithful Shapley values
|
|
237
209
|
fsii_values.plot_force() # plot the force plot
|
|
238
210
|
```
|
|
239
211
|
|
|
@@ -241,6 +213,28 @@ fsii_values.plot_force() # plot the force plot
|
|
|
241
213
|
<img width="800px" src="https://raw.githubusercontent.com/mmschlk/shapiq/main/docs/source/_static/images/fsii_tabpfn_force_plot_example.png" alt="Force Plot of FSII values as derived from the example tabpfn notebook">
|
|
242
214
|
</p>
|
|
243
215
|
|
|
216
|
+
### Use SPEX (SParse EXplainer) <img src="https://raw.githubusercontent.com/mmschlk/shapiq/main/docs/source/_static/images/spex_logo.png" alt="spex_logo" align="right" height="75px"/>
|
|
217
|
+
For large-scale use-cases you can also check out the [👓``SPEX``](https://shapiq.readthedocs.io/en/latest/api/shapiq.approximator.sparse.html#shapiq.approximator.sparse.SPEX) approximator.
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
# load your data and model with large number of features
|
|
221
|
+
data, model, n_features = ...
|
|
222
|
+
|
|
223
|
+
# use the SPEX approximator directly
|
|
224
|
+
approximator = shapiq.SPEX(n=n_features, index="FBII", max_order=2)
|
|
225
|
+
fbii_scores = approximator.approximate(budget=2000, game=model.predict)
|
|
226
|
+
|
|
227
|
+
# or use SPEX with an explainer
|
|
228
|
+
explainer = shapiq.Explainer(
|
|
229
|
+
model=model,
|
|
230
|
+
data=data,
|
|
231
|
+
index="FBII",
|
|
232
|
+
max_order=2,
|
|
233
|
+
approximator="spex" # specify SPEX as approximator
|
|
234
|
+
)
|
|
235
|
+
explanation = explainer.explain(data[0])
|
|
236
|
+
```
|
|
237
|
+
|
|
244
238
|
|
|
245
239
|
## 📖 Documentation with tutorials
|
|
246
240
|
The documentation of ``shapiq`` can be found at https://shapiq.readthedocs.io.
|
|
@@ -252,7 +246,7 @@ There is a lot of great resources available to get you started with Shapley valu
|
|
|
252
246
|
If you use ``shapiq`` and enjoy it, please consider citing our [NeurIPS paper](https://arxiv.org/abs/2410.01649) or consider starring this repository.
|
|
253
247
|
|
|
254
248
|
```bibtex
|
|
255
|
-
@inproceedings{
|
|
249
|
+
@inproceedings{Muschalik.2024b,
|
|
256
250
|
title = {shapiq: Shapley Interactions for Machine Learning},
|
|
257
251
|
author = {Maximilian Muschalik and Hubert Baniecki and Fabian Fumagalli and
|
|
258
252
|
Patrick Kolpaczki and Barbara Hammer and Eyke H\"{u}llermeier},
|
|
@@ -279,10 +273,52 @@ Some authors acknowledge the financial support by the German Research Foundation
|
|
|
279
273
|
---
|
|
280
274
|
Built with ❤️ by the shapiq team.
|
|
281
275
|
|
|
282
|
-
|
|
283
276
|
## Changelog
|
|
284
277
|
|
|
285
|
-
###
|
|
278
|
+
### v1.3.0 (2025-06-17)
|
|
279
|
+
|
|
280
|
+
#### Highlights
|
|
281
|
+
- `shapiq.SPEX` (Sparse Exact) approximator for efficient computation of sparse interaction values for really large models and games. Paper: [SPEX: Scaling Feature Interaction Explanations for LLMs](https://arxiv.org/abs/2502.13870)
|
|
282
|
+
- `shapiq.AgnosticExplainer` a generic explainer that works for any value function or `shapiq.Game` object, allowing for more flexibility in explainers.
|
|
283
|
+
- prettier graph-based plots via `shapiq.si_graph_plot()` and `shapiq.network_plot()`, which now use the same backend for more flexibility and easier maintenance.
|
|
284
|
+
|
|
285
|
+
#### New Features
|
|
286
|
+
- adds the SPEX (Sparse Exact) module in `approximator.sparse` for efficient computation of sparse interaction values [#379](https://github.com/mmschlk/shapiq/pull/379)
|
|
287
|
+
- adds `shapiq.AgnosticExplainer` which is a generic explainer that can be used for any value function or `shapiq.Game` object. This allows for more flexibility in the explainers. [#100](https://github.com/mmschlk/shapiq/issues/100), [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
288
|
+
- changes `budget` to be a mandatory parameter given to the `TabularExplainer.explain()` method [#355](https://github.com/mmschlk/shapiq/pull/356)
|
|
289
|
+
- changes logic of `InteractionValues.get_n_order()` function to be callable with **either** the `order: int` parameter and optional assignment of `min_order: int` and `max_order: int` parameters **or** with the min/max order parameters [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
290
|
+
- renamed `min_percentage` parameter in the force plot to `contribution_threshold` to better reflect its purpose [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
291
|
+
- adds ``verbose`` parameter to the ``Explainer``'s ``explain_X()`` method to control weather a progress bar is shown or not which is defaulted to ``False``. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
292
|
+
- made `InteractionValues.get_n_order()` and `InteractionValues.get_n_order_values()` function more efficient by iterating over the stored interactions and not over the powerset of all potential interactions, which made the function not usable for higher player counts (models with many features, and results obtained from `TreeExplainer`). Note, this change does not really help `get_n_order_values()` as it still needs to create a numpy array of shape `n_players` times `order` [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
293
|
+
- streamlined the ``network_plot()`` plot function to use the ``si_graph_plot()`` as its backend function. This allows for more flexibility in the plot function and makes it easier to use the same code for different purposes. In addition, the ``si_graph_plot`` was modified to make plotting more easy and allow for more flexibility with new parameters. [#349](https://github.com/mmschlk/shapiq/pull/349)
|
|
294
|
+
- adds `Game.compute()` method to the `shapiq.Game` class to compute game values without changing the state of the game object. The compute method also introduces a `shapiq.utils.sets.generate_interaction_lookup_from_coalitions()` utility method which creates an interaction lookup dict from an array of coalitions. [#397](https://github.com/mmschlk/shapiq/pull/397)
|
|
295
|
+
- streamlines the creation of network plots and graph plots which now uses the same backend. The network plot via `shapiq.network_plot()` or `InteractionValues.plot_network()` is now a special case of the `shapiq.si_graph_plot()` and `InteractionValues.plot_si_graph()`. This allows to create more beautiful plots and easier maintenance in the future. [#349](https://github.com/mmschlk/shapiq/pull/349)
|
|
296
|
+
|
|
297
|
+
#### Testing, Code-Quality and Documentation
|
|
298
|
+
- activates ``"ALL"`` rules in ``ruff-format`` configuration to enforce stricter code quality checks and addressed around 500 (not automatically solvable) issues in the code base. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
299
|
+
- improved the testing environment by adding a new fixture module containing mock `InteractionValues` objects to be used in the tests. This allows for more efficient and cleaner tests, as well as easier debugging of the tests [#372](https://github.com/mmschlk/shapiq/pull/372)
|
|
300
|
+
- removed check and error message if the ``index`` parameter is not in the list of available indices in the ``TabularExplainer`` since the type hints were replaced by Literals [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
301
|
+
- removed multiple instances where ``shapiq`` tests if some approximators/explainers can be instantiated with certain indices or not in favor of using Literals in the ``__init__`` method of the approximator classes. This allows for better type hinting and IDE support, as well as cleaner code. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
302
|
+
- Added documentation for all public modules, classes, and functions in the code base to improve the documentation quality and make it easier to understand how to use the package. [#391](https://github.com/mmschlk/shapiq/pull/391)
|
|
303
|
+
- suppress a ``RuntimeWarning`` in ``Regression`` approximators ``solve_regression()``method when the solver is not able to find good interim solutions for the regression problem.
|
|
304
|
+
- refactors the tests into ``tests_unit/`` and ``tests_integration/`` to better separate unit tests from integration tests. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
305
|
+
- adds new integration tests in ``tests/tests_integration/test_explainer_california_housing`` which compares the different explainers against ground-truth interaction values computed by ``shapiq.ExactComputer`` and interaction values stored on [disk](https://github.com/mmschlk/shapiq/tree/main/tests/data/interaction_values/california_housing) as a form of regression test. This test should help finding bugs in the future when the approximators, explainers, or exact computation are changed. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
306
|
+
|
|
307
|
+
#### Bug Fixes
|
|
308
|
+
- fixed a bug in the `shapiq.waterfall_plot` function that caused the plot to not display correctly resulting in cutoff y_ticks. Additionally, the file was renamed from `watefall.py` to `waterfall.py` to match the function name [#377](https://github.com/mmschlk/shapiq/pull/377)
|
|
309
|
+
- fixes a bug with `TabPFNExplainer`, where the model was not able to be used for predictions after it was explained. This was due to the model being fitted on a subset of features, which caused inconsistencies in the model's predictions after explanation. The fix includes that after each call to the `TabPFNImputer.value_function`, the tabpfn model is fitted on the whole dataset (without omitting features). This means that the original model can be used for predictions after it has been explained. [#396](https://github.com/mmschlk/shapiq/issues/396).
|
|
310
|
+
- fixed a bug in computing `BII` or `BV` indices with `shapiq.approximator.MonteCarlo` approximators (affecting `SHAP-IQ`, `SVARM` and `SVARM-IQ`). All orders of BII should now be computed correctly. [#395](https://github.com/mmschlk/shapiq/pull/395)
|
|
311
|
+
|
|
312
|
+
### v1.2.3 (2025-03-24)
|
|
313
|
+
- substantially improves the runtime of all `Regression` approximators by a) a faster pre-computation of the regression matrices and b) a faster computation of the weighted least squares regression [#340](https://github.com/mmschlk/shapiq/issues/340)
|
|
314
|
+
- removes `sample_replacements` parameter from `MarginalImputer` and removes the DeprecationWarning for it
|
|
315
|
+
- adds a trivial computation to `TreeSHAP-IQ` for trees that use only one feature in the tree (this works for decision stumps or trees splitting on only one feature multiple times). In such trees, the computation is trivial as the whole effect of $\nu(N) - \nu(\emptyset)$ is all on the main effect of the single feature and there is no interaction effect. This expands on the fix in v1.2.1 [#286](https://github.com/mmschlk/shapiq/issues/286).
|
|
316
|
+
- fixes a bug with xgboost where feature names where trees that did not contain all features would lead `TreeExplainer` to fail
|
|
317
|
+
- fixes a bug with `stacked_bar_plot` where the higher order interactions were inflated by the lower order interactions, thus wrongly showing the higher order interactions as higher than they are
|
|
318
|
+
- fixes a bug where `InteractionValues.get_subset()` returns a faulty `coalition_lookup` dictionary pointing to indices outside the subset of players [#336](https://github.com/mmschlk/shapiq/issues/336)
|
|
319
|
+
- updates default value of `TreeExplainer`'s `min_order` parameter from 1 to 0 to include the baseline value in the interaction values as per default
|
|
320
|
+
- adds the `RegressionFBII` approximator to estimate Faithful Banzhaf interactions via least squares regression [#333](https://github.com/mmschlk/shapiq/pull/333). Additionally, FBII support was introduced in TabularExplainer and MonteCarlo-Approximator.
|
|
321
|
+
- adds a `RandomGame` class as part of `shapiq.games.benchmark` which always returns a random vector of integers between 0 and 100.
|
|
286
322
|
|
|
287
323
|
### v1.2.2 (2025-03-11)
|
|
288
324
|
- changes python support to 3.10-3.13 [#318](https://github.com/mmschlk/shapiq/pull/318)
|
|
@@ -11,13 +11,21 @@
|
|
|
11
11
|
[](https://pepy.tech/project/shapiq)
|
|
12
12
|
|
|
13
13
|
[](https://github.com/psf/black)
|
|
14
|
+
[](https://github.com/mmschlk/shapiq/issues)
|
|
15
|
+
[](https://github.com/mmschlk/shapiq/commits/main)
|
|
14
16
|
|
|
15
17
|
> An interaction may speak more than a thousand main effects.
|
|
16
18
|
|
|
17
19
|
Shapley Interaction Quantification (`shapiq`) is a Python package for (1) approximating any-order Shapley interactions, (2) benchmarking game-theoretical algorithms for machine learning, (3) explaining feature interactions of model predictions. `shapiq` extends the well-known [shap](https://github.com/shap/shap) package for both researchers working on game theory in machine learning, as well as the end-users explaining models. SHAP-IQ extends individual Shapley values by quantifying the **synergy** effect between entities (aka **players** in the jargon of game theory) like explanatory features, data points, or weak learners in ensemble models. Synergies between players give a more comprehensive view of machine learning models.
|
|
18
20
|
|
|
19
21
|
## 🛠️ Install
|
|
20
|
-
`shapiq` is intended to work with **Python 3.10 and above**.
|
|
22
|
+
`shapiq` is intended to work with **Python 3.10 and above**.
|
|
23
|
+
Installation can be done via `uv` :
|
|
24
|
+
```sh
|
|
25
|
+
uv add shapiq
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or via `pip`:
|
|
21
29
|
|
|
22
30
|
```sh
|
|
23
31
|
pip install shapiq
|
|
@@ -31,6 +39,7 @@ If you are interested in the underlying game theoretic algorithms, then check ou
|
|
|
31
39
|
### Compute any-order feature interactions
|
|
32
40
|
|
|
33
41
|
Explain your models with Shapley interactions:
|
|
42
|
+
Just load your data and model, and then use a `shapiq.Explainer` to compute Shapley interactions.
|
|
34
43
|
|
|
35
44
|
```python
|
|
36
45
|
import shapiq
|
|
@@ -129,7 +138,7 @@ The pseudo-code above can produce the following plot (here also an image is adde
|
|
|
129
138
|
|
|
130
139
|
### Explain TabPFN
|
|
131
140
|
|
|
132
|
-
With ``shapiq`` you can also [``TabPFN``](https://github.com/PriorLabs/TabPFN) by making use of the _remove-and-recontextualize_ explanation paradigm implemented in ``shapiq.TabPFNExplainer``.
|
|
141
|
+
With ``shapiq`` you can also explain [``TabPFN``](https://github.com/PriorLabs/TabPFN) by making use of the _remove-and-recontextualize_ explanation paradigm implemented in ``shapiq.TabPFNExplainer``.
|
|
133
142
|
|
|
134
143
|
```python
|
|
135
144
|
import tabpfn, shapiq
|
|
@@ -142,7 +151,7 @@ explainer = shapiq.TabPFNExplainer( # setup the explainer
|
|
|
142
151
|
labels=labels,
|
|
143
152
|
index="FSII"
|
|
144
153
|
)
|
|
145
|
-
fsii_values = explainer.explain(
|
|
154
|
+
fsii_values = explainer.explain(data[0]) # explain with Faithful Shapley values
|
|
146
155
|
fsii_values.plot_force() # plot the force plot
|
|
147
156
|
```
|
|
148
157
|
|
|
@@ -150,6 +159,28 @@ fsii_values.plot_force() # plot the force plot
|
|
|
150
159
|
<img width="800px" src="https://raw.githubusercontent.com/mmschlk/shapiq/main/docs/source/_static/images/fsii_tabpfn_force_plot_example.png" alt="Force Plot of FSII values as derived from the example tabpfn notebook">
|
|
151
160
|
</p>
|
|
152
161
|
|
|
162
|
+
### Use SPEX (SParse EXplainer) <img src="https://raw.githubusercontent.com/mmschlk/shapiq/main/docs/source/_static/images/spex_logo.png" alt="spex_logo" align="right" height="75px"/>
|
|
163
|
+
For large-scale use-cases you can also check out the [👓``SPEX``](https://shapiq.readthedocs.io/en/latest/api/shapiq.approximator.sparse.html#shapiq.approximator.sparse.SPEX) approximator.
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# load your data and model with large number of features
|
|
167
|
+
data, model, n_features = ...
|
|
168
|
+
|
|
169
|
+
# use the SPEX approximator directly
|
|
170
|
+
approximator = shapiq.SPEX(n=n_features, index="FBII", max_order=2)
|
|
171
|
+
fbii_scores = approximator.approximate(budget=2000, game=model.predict)
|
|
172
|
+
|
|
173
|
+
# or use SPEX with an explainer
|
|
174
|
+
explainer = shapiq.Explainer(
|
|
175
|
+
model=model,
|
|
176
|
+
data=data,
|
|
177
|
+
index="FBII",
|
|
178
|
+
max_order=2,
|
|
179
|
+
approximator="spex" # specify SPEX as approximator
|
|
180
|
+
)
|
|
181
|
+
explanation = explainer.explain(data[0])
|
|
182
|
+
```
|
|
183
|
+
|
|
153
184
|
|
|
154
185
|
## 📖 Documentation with tutorials
|
|
155
186
|
The documentation of ``shapiq`` can be found at https://shapiq.readthedocs.io.
|
|
@@ -161,7 +192,7 @@ There is a lot of great resources available to get you started with Shapley valu
|
|
|
161
192
|
If you use ``shapiq`` and enjoy it, please consider citing our [NeurIPS paper](https://arxiv.org/abs/2410.01649) or consider starring this repository.
|
|
162
193
|
|
|
163
194
|
```bibtex
|
|
164
|
-
@inproceedings{
|
|
195
|
+
@inproceedings{Muschalik.2024b,
|
|
165
196
|
title = {shapiq: Shapley Interactions for Machine Learning},
|
|
166
197
|
author = {Maximilian Muschalik and Hubert Baniecki and Fabian Fumagalli and
|
|
167
198
|
Patrick Kolpaczki and Barbara Hammer and Eyke H\"{u}llermeier},
|