forked from mmschlk/shapiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
327 lines (306 loc) · 10.6 KB
/
Copy pathpyproject.toml
File metadata and controls
327 lines (306 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
[build-system]
requires = ["setuptools>=69", "wheel", "setuptools_scm>=8", "numpy"]
build-backend = "setuptools.build_meta"
[project]
name = "shapiq"
dynamic = ["readme", "version"]
description = "Shapley Interactions for Machine Learning"
requires-python = ">=3.12"
dependencies = [
# core
"numpy",
"scipy",
"pandas",
"joblib",
"scikit-learn",
"tqdm",
"requests",
# plotting
"matplotlib",
"networkx",
"colour",
"pillow",
]
authors = [
{name = "Maximilian Muschalik", email = "Maximilian.Muschalik@lmu.de"},
{name = "Santo M. A. R. Thies", email = "Santo.Thies@lmu.de"},
{name = "Hubert Baniecki", email = "h.baniecki@uw.edu.pl"},
{name = "Fabian Fumagalli", email = "ffumagalli@techfak.de"},
]
maintainers = [
{name = "Maximilian Muschalik", email = "Maximilian.Muschalik@lmu.de"},
{name = "Santo M. A. R. Thies", email = "Santo.Thies@lmu.de"},
]
license = "MIT"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
'Operating System :: Microsoft :: Windows',
'Operating System :: Unix',
'Operating System :: MacOS',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
]
keywords = [
"python",
"machine learning",
"interpretable machine learning",
"shap",
"xai",
"explainable ai",
"interaction",
"shapley interactions",
"shapley values",
"feature interaction",
]
[project.optional-dependencies]
sparse = [
# required by shapiq.approximator.sparse (SPEX and the Sparse base class)
"sparse-transform",
"galois",
]
proxy = [
# required by shapiq.approximator.proxy (ProxySHAP, ProxySPEX, RegressionMSR)
"xgboost", # default proxy model in ProxySHAP
"lightgbm", # required by ProxySPEX
"catboost",
"smac", # SMAC HPO for proxy models
]
shapleig = [
# required by shapiq.approximator.shapleig (ShaplEIG)
# NOTE: lower bounds are the versions the reference implementation was
# developed and validated against.
"torch>=2.9.1",
"gpytorch>=1.14",
"botorch>=0.14.0",
"linear_operator>=0.6", # also a transitive gpytorch dependency, but imported directly
]
benchmark = [
# optional model backends for shapiq_benchmark, imported lazily
"optuna",
"tabpfn",
"lightgbm",
"xgboost",
]
[tool.coverage.report]
exclude_also = [
'if TYPE_CHECKING:',
]
[tool.setuptools_scm]
write_to = "src/shapiq/_version.py"
[tool.setuptools.packages.find]
where = ["./src"]
include = ["shapiq*", "lazy_dispatch"]
[tool.setuptools.dynamic]
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
[project.urls]
documentation = "https://shapiq.readthedocs.io"
source = "https://github.com/mmschlk/shapiq"
tracker = "https://github.com/mmschlk/shapiq/issues"
changelog = "https://github.com/mmschlk/shapiq/blob/main/CHANGELOG.md"
[tool.pytest.ini_options]
testpaths = [
"tests/shapiq",
"tests/shapiq_games",
"tests/shapiq_benchmark"
]
pythonpath = ["src"]
minversion = "8.0"
[tool.ruff]
line-length = 100
target-version = "py312"
src = ["tests", "src", "docs"]
[tool.ruff.lint]
# we allow star arguments to be of type Any e.g. def func(*args: Any, **kwargs: Any) -> None: is ok
flake8-annotations.allow-star-arg-any = true
select = ["ALL"]
ignore = [
"E501", # Line too long
"N803", # Variable X in function should be lowercase
"N806", # Variable X in function should be lowercase
"COM812", # this is redundant with the formatter which anyways does this (must be excluded) in the future # TODO: add remove pickle calls and remove this exclusion
"FIX002", # we use TODOs atm to track potential code improvements # TODO: add this in the future
"PLR0913", # Too many arguments are passed to function
"PLR0915", # Too many statements in function
"PLR0912", # Too many branches in function
"PLR2004", # Magic values in comparison ... this gets flaged with all checks for two-way interactions
"C901", # Too complex functions
"PLR0911", # too many return statements in function
"N802", # Function name should be lowercase
]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
"docs/build",
]
# Exclude a variety of commonly ignored directories.
# Note to developers: If you add a new ignore at least put a comment next to it why it is ignored
[tool.ruff.lint.per-file-ignores]
"src/shapiq/approximator/shapleig/_shapley_math.py" = [
# controlled verbatim copy of the validated reference implementation in
# the ShaplEIG research repository; kept in sync, not restyled
"ANN001", "ANN202", # reference code is fully typed via annotations where it matters
"FBT001", "FBT002", # boolean positional args of internal helpers
"N815", # tensor names follow the paper notation (train_X, ...)
"PERF401", # explicit loops mirror the published algorithm
"RUF002", "RUF003", # mathematical notation in docstrings/comments
"S101", # shape/consistency asserts of the math core
]
"src/shapiq/approximator/shapleig/_kernels.py" = [
"FBT001", "FBT002", # signature dictated by gpytorch's Kernel.forward
]
"src/shapiq/typing.py" = [
"A005", # we want to be similar to other libraries that also shadow typing
"D102", # we don't need docstrings for protocol stubs
"ANN401", # any return type is okay in typing.py for protocol subts
]
"tests/*.py" = [
# "ALL",
"S101", # we need asserts in tests
"D", # test docstrings don't matter too much
"E501", # line too long
"ANN", # type annotations
"ARG", # some functions are not used
"INP", # inports can be different
"N", # type hints are excludes in tests
"PTH", # we can use os for now
"S", # in tests we can use some security issues for now
"PT", # we can use print statements in tests
"NPY",
"SLF", # private members are okay in tests
"TRY",
]
"examples/**/*.py" = [
"E402", # Module level import not at top of file
"T20", # examples can have print statements
"I002", # examples do not have to import required modules
"D", # docstrings are not required in examples
"SLF001", # private members are okay in examples
"ANN001", # type annotations are not required in examples
"INP", # examples are an implicit namespace package
]
"docs/source/*.py" = [
"A001", # some conf.py variables shadow builtins which is okay here
"ANN001", # some magic functions I don't want to annotate
"INP", # docs can be an implicit package (does not need to be imported)
"I002", # benchmark code does not have to import required modules
]
"benchmark/*.py" = [
"INP", # imports can be different here
"I002", # benchmark code does not have to import required modules
"PTH" # in benchmark code we use a lot of os, which is okay
]
"__init__.py" = [
"I002", # __init__.py does not have to import required modules
"RUF022", # we can have unsorted imports in __init__.py
"FA",
]
"scripts/*.py" = [
"INP", # imports can be different here
"I002", # script code does not have to import required modules
"PTH", # in script code we use a lot of os, which is okay
"T201", # scripts can have print statements
"BLE001", # scripts can have bare excepts
"TRY"
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ty.src]
include = ["src/shapiq"]
exclude = ["tests", "docs", "benchmark", "scripts", "src/shapiq_games"]
[tool.ty.environment]
python-version = "3.12"
python = "./.venv"
python-platform = "linux"
[tool.cibuildwheel]
build = ["cp312-*", "cp313-*", "cp314-*"]
skip = ["*-win32", "*-manylinux_i686", "pp*", "*musllinux*"]
build-frontend = "uv"
test-command = "python -c \"import shapiq; from shapiq.tree.conversion import cext; from shapiq.tree.interventional import cext; from shapiq.tree.linear import cext; print('C extensions OK')\""
[tool.cibuildwheel.linux]
manylinux-x86_64-image = "manylinux_2_28"
[tool.cibuildwheel.macos]
# libomp is installed by build_tools/wheels/build_wheels.sh (pinned conda-forge
# tarball, not brew) so wheels can target an old MACOSX_DEPLOYMENT_TARGET.
[tool.cibuildwheel.windows]
# MSVC ships OpenMP runtime (vcomp140.dll) with Visual C++ Redistributable
# No extra setup needed; /openmp flag in setup.py handles everything
[tool.ruff.lint.isort]
known-first-party = ["shapiq"]
extra-standard-library = ["typing_extensions"]
combine-as-imports = true
force-wrap-aliases = true
no-lines-before = ["future"]
required-imports = ["from __future__ import annotations"]
[dependency-groups]
all_ml = [
"tabpfn>=2.1.3",
"torchvision",
"torch",
"xgboost",
"lightgbm", # lightgbm has install problems on macOS in github actions
"catboost",
"transformers",
"scikit-image",
"tensorflow; python_version < '3.13' and platform_system != 'Windows'", # only up to py 3.12
"tf-keras; python_version < '3.13' and platform_system != 'Windows'", # only up to py 3.12
]
test = [
"pytest>=9.0.2", # for running tests
"pytest-cov>=7.0.0", # for coverage
"pytest-xdist>=3.8.0", # for parallel test execution
"packaging", # for version parsing in tests
]
lint = [
"ruff>=0.14.1", # for linting
"pre-commit>=4.3.0", # for running the linters pre-commit hooks
"ty>=0.0.21", # for type checking
]
docs = [
"sphinx>=9.1.0", # documentation generator
"furo", # beautiful sphinx theme
"myst-parser", # Markdown support for Sphinx
"sphinx-copybutton", # copy button for code blocks
"sphinx-autodoc-typehints", # include typehints in docs
"sphinxcontrib-bibtex", # references based on bibtex
"ipython>=9.0.0", # for code execution in sphinx-gallery
"sphinx-gallery", # gallery of examples from Python scripts
"matplotlib", # required for sphinx-gallery thumbnails
{include-group = "all_ml"}
]
dev = [
"notebook>=7.3.3",
"ipywidgets",
{include-group = "test"},
{include-group = "lint"},
{include-group = "all_ml"},
]