Skip to content

fix: support current shap, pandas, numpy and Python versions (1.0.5) - #64

Open
saleiro wants to merge 6 commits into
feedzai:mainfrom
saleiro:release/1.0.5
Open

saleiro wants to merge 6 commits into
feedzai:mainfrom
saleiro:release/1.0.5

Conversation

@saleiro

@saleiro saleiro commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Context

pip install timeshap installs 1.0.4, and timeshap.explainer fails to import with shap 0.43 or later (#48, #56).
pandas 2, scipy 1.11, numpy 2.5 and IPython 9 break other functions and the notebooks. No workflow ran the tests, so
these breaks went unnoticed.

Solution

1.0.5 supports Python 3.10 to 3.14, shap 0.42.1 to 0.53, numpy 1.22 to 2.x and pandas 1.4 to 3.x. It also fixes the
global functions without entity_col, pruning inside event_explain_all and feat_explain_all, a time column given as
an index, CSV files on Windows, and a circular import between timeshap.plot and timeshap.explainer. Explanations do
not change: on shap 0.42.1, 1.0.4 and 1.0.5 return byte-identical local and global reports. Packaging moves to
pyproject.toml, and import timeshap no longer enables the Feedzai Altair theme. CHANGELOG.md lists every
user-visible change.

Two report tests compared against reference values that no shap version from 0.42.1 to 0.53 produces. They now hold the
values the code returns.

Testing

tests.yml runs pytest on Python 3.10 to 3.14 on Linux, on 3.12 on Windows and macOS, and with the oldest supported
dependencies. It also runs the three AReM notebooks and twine check. Locally, the 43 tests pass on Python 3.10 to 3.14
and on the oldest dependencies, and the three notebooks run end to end. I did not run the workflows on GitHub before
opening this PR.

Before merging

publish.yml replaces main.yml. It runs the tests first, then publishes with the PYPI_API_TOKEN secret, as
main.yml did.

References

Closes #48, closes #49, closes #50, closes #56, closes #61, closes #62.

Includes the change from #63 and supersedes #58.

Comment thread .github/workflows/tests.yml Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread src/timeshap/explainer/event_level.py Resolved
Comment thread src/timeshap/utils/utils.py Resolved
Comment thread src/timeshap/utils/utils.py Resolved

@sgpjesus sgpjesus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small comments to solve existing and potential issues with actions changes.

shap 0.43 renamed Kernel to KernelExplainer, so timeshap.explainer failed
to import (feedzai#48, feedzai#56). plot_global_feat averaged non-numeric columns, which
pandas 2 rejects (feedzai#62). calc_avg_event and calc_avg_sequence used
scipy.stats.mode, which changed shape and refuses text in scipy 1.11; a
local _mode helper replaces it. get_avg_score_with_avg_event called
float() on a one-element array, which numpy 2.5 rejects.

convert_to_indexes checked entity_col instead of time_col, so a time
column given as an index did not sort the sequences.

Two report tests compared against reference values that no shap version
from 0.42.1 to 0.53 produces. They now hold the values the code returns,
which match 1.0.4 on shap 0.42.1. The test folders get __init__.py files
so pytest can collect the two test_utils.py modules.
…, UTF-8 files

prune_all, event_explain_all and feat_explain_all failed without
entity_col. A sequence is now identified by its position in the data.

event_explain_all and feat_explain_all with a tolerance and no
pruning_data unpacked an int and read data.shape from a list. They now
compute the pruning for each sequence.

The verify_*_dict functions changed the caller's dict, so a dict reused
for a local report after a global report failed validation. They now
return a normalized copy.

Explanation CSV files are written as UTF-8. The coalition labels contain
"≤", which the Windows default encoding cannot write (feedzai#50).

timeshap.plot imported timeshap.explainer at load time, and the reverse,
so importing timeshap.plot first failed (feedzai#49). The plot functions now
import the two explainer helpers they use when they run.
Requires Python 3.10+. Dependency ranges are the ones the tests run
against: numpy 1.22 to 2.x, pandas 1.4 to 3.x, scipy 1.8 to 1.x,
altair 4.2 to 6.x, and shap 0.42.1 to 0.53. shap keeps an upper bound
because TimeSHAP imports its private modules and relies on
l1_reg="auto", which shap has deprecated.

seaborn, plotly, matplotlib and scikit-learn were never imported.
import timeshap no longer enables the Feedzai Altair theme for the whole
session, so feedzai-altair-theme is dropped as well. torch is available
as the torch extra.
tests.yml runs pytest on Python 3.10 to 3.14 on Linux, on 3.12 on Windows
and macOS, and with the oldest supported dependencies. It also runs the
three AReM notebooks and checks the built distribution. setup-uv is
pinned to a commit because the action publishes no major version tag.

publish.yml replaces main.yml. It runs tests.yml first, then builds and
publishes with the PYPI_API_TOKEN secret.
CONTRIBUTING.md covers setup, tests, notebooks and releases (feedzai#61).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants