Skip to content
Merged

Dev #55

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1f1c458
migrate from poetry to uv + change validate_data
Sep 23, 2025
da0ebb7
Updated validate_data with new version
Sep 23, 2025
e46cf89
updated test.yml to v5 and migrated to uv
Sep 24, 2025
83d3b03
apparently artifact@v5 does not yet exist in test.yml
Sep 24, 2025
42728a0
added if statement for windows in test.yml
Sep 24, 2025
a8bf9a1
make unique name for artifacts test.yml
Sep 24, 2025
6b80265
windows dependency
Sep 24, 2025
4d8f75b
changed removed tensorflow support
Sep 24, 2025
34b7442
changed files to support new validate_data
Sep 24, 2025
9bfca6d
update test_shap_explainer to remove deeplearning
Sep 24, 2025
9427a1a
fixed overloading in shap_explainer.py
Sep 24, 2025
f53d5a7
changed deprecated force_all_finite to supported ensure_all_finite in…
Sep 24, 2025
5028726
changed input tags of estimator
Sep 24, 2025
f68f549
changed transform to private version because it does not call an inte…
Sep 24, 2025
c4ce708
forgot to delete input tags
Sep 24, 2025
1b5be90
back to public transform and added sklearn_tags
Sep 24, 2025
24367be
updated statsmodels dependency
Sep 24, 2025
0f75130
dep
Sep 24, 2025
b84e939
faster testing with caching
Sep 24, 2025
9e07c2e
debug code
Sep 24, 2025
2d93972
inhomogeneous fix
Sep 24, 2025
edd3290
-
Sep 24, 2025
39bc015
added logs
Sep 24, 2025
a906fdf
hope it is fixed now
Sep 24, 2025
6d63d2d
pray
Sep 24, 2025
8ca1173
added tests for python 3.13
Sep 25, 2025
45c8876
forgot uv.lock
Sep 25, 2025
90ed570
added support for fitkwargs in the fit (issue 45)
Sep 25, 2025
7b5137d
added documentation
Sep 25, 2025
894c644
changed to powershap 0.1.0
Sep 25, 2025
f6a478d
added support and tests for pipeline explainer
Sep 25, 2025
6e6dbfd
import error fix
Sep 25, 2025
339f1cc
fixing circular dependency
Sep 25, 2025
e0b224a
support_model fix
Sep 25, 2025
f0b39d0
changed support_model to issubclass instead of isinstance for pipeline
Sep 25, 2025
aa962e6
bugfixes for pipeline explainer
Sep 25, 2025
41b44dd
fixing some pipeline tests
Sep 25, 2025
a70615a
new test incoming
Sep 25, 2025
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
60 changes: 27 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
paths:
- "powershap/**"
- "tests/**"
- "poetry.lock"
- "uv.lock"
- ".github/workflows/test.yml"
pull_request:
branches: [ main ]
paths:
- "powershap/**"
- "tests/**"
- "poetry.lock"
- "uv.lock"
- ".github/workflows/test.yml"

jobs:
Expand All @@ -26,54 +26,48 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest'] # TODO - do we add other OSes?
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: ['ubuntu-latest', 'windows-latest'] # TODO - do we add other OSes?
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install llvm on Ubuntu
if: runner.os == 'Linux'
run: sudo apt-get install llvm # Because https://github.com/slundberg/shap/issues/1854

- name: Install MSVC build tools on Windows
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v1

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
- name: Cache poetry
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-python-${{ matrix.python-version }}
- run: poetry --version

- run: sudo apt-get install llvm # Because https://github.com/slundberg/shap/issues/1854
- name: Install dependencies
run: poetry install --all-extras
# Do not use caching (anymore)
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: uv sync --locked --all-extras --dev

# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest

run: |
poetry run pytest --cov=powershap --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov-report=xml tests
uv run pytest --cov=powershap --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov-report=xml tests

- name: Upload pytest test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
name: pytest-results-${{ matrix.python-version }}-${{matrix.os}}
path: junit/test-results-${{ matrix.python-version }}-${{matrix.os}}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
2,438 changes: 0 additions & 2,438 deletions poetry.lock

This file was deleted.

17 changes: 12 additions & 5 deletions powershap/powershap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from sklearn.base import BaseEstimator
from sklearn.feature_selection import SelectorMixin
from sklearn.model_selection import BaseCrossValidator
from sklearn.utils.validation import check_is_fitted
from sklearn.utils.validation import check_is_fitted,validate_data



from .shap_wrappers import ShapExplainerFactory
from .utils import powerSHAP_statistical_analysis
Expand Down Expand Up @@ -365,19 +367,21 @@ def fit(self, X, y, stratify=None, groups=None, **kwargs):
# Perform the necessary sklearn checks -> X and y are both ndarray.
# Logs the feature names as well (in self.feature_names_in_ in sklearn 1.x).
#
# These two operations (_validate_data and pd.DataFrame) will also copy
# These two operations (validate_data and pd.DataFrame) will also copy
# the data into a new place in memory, avoiding data mutation. How this
# happens may not be obvious at first glance:
#
# 1. _validate_data ensures that the data is a numpy array, copying it
# 1. validate_data ensures that the data is a numpy array, copying it
# upon conversion if necessary.
#
# 2. pd.DataFrame then copies X, which is now an numpy array, into a
# new pandas dataframe.
#
# If this is changed in some way which would allow explain() to mutate
# the original data, it should cause the data mutation tests to fail.
X, y = self._explainer._validate_data(self._validate_data, X, y, multi_output=True)

# X, y = validate_data(self, X, y, multi_output=True)
X, y = self._explainer.validate_data(self, X, y, multi_output=True)
X = pd.DataFrame(data=X, columns=list(range(X.shape[1])))

self._print("Starting powershap")
Expand Down Expand Up @@ -530,5 +534,8 @@ def transform(self, X):
)
return super().transform(X)

def _more_tags(self):
# Since sklearn 1.6, the tag system changed so this function is necessary to make it compatible
# https://scikit-learn.org/stable/auto_examples/release_highlights/plot_release_highlights_1_6_0.html#improvements-to-the-developer-api-for-third-party-libraries
def __sklearn_tags__(self):
return self._explainer._get_more_tags()

Loading
Loading