Skip to content

Commit 59b5a6a

Browse files
Merge pull request #297 from ThomasBouche/feature/replace_3_6_by_3_10
support for python 3.10 and deletion of support 3.6
2 parents b6abb31 + 71888dc commit 59b5a6a

File tree

10 files changed

+60
-48
lines changed

10 files changed

+60
-48
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
max-parallel: 1
1010
matrix:
11-
python-version: [3.6, 3.7, 3.8, 3.9]
11+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Set up Python ${{ matrix.python-version }}
@@ -28,12 +28,12 @@ jobs:
2828
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
2929
- name: Test with pytest
3030
run: |
31-
pytest
31+
python -m pytest
3232
- name: Build python package
3333
run: |
3434
python setup.py sdist bdist_wheel
3535
- name: Deploy to PyPI
36-
if: success() && startsWith(github.ref, 'refs/tags') && matrix.python-version == 3.9
36+
if: success() && startsWith(github.ref, 'refs/tags') && matrix.python-version == '3.10'
3737
uses: pypa/gh-action-pypi-publish@master
3838
with:
3939
user: __token__

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Shapash can use category-encoders object, sklearn ColumnTransformer or simply fe
161161

162162
## 🛠 Installation
163163

164-
Shapash is intended to work with Python versions 3.6 to 3.9. Installation can be done with pip:
164+
Shapash is intended to work with Python versions 3.7 to 3.10. Installation can be done with pip:
165165

166166
```
167167
pip install shapash

requirements.dev.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
pip==21.3.1
2+
numpy>=1.18.0
23
dash==2.3.1
3-
catboost==0.26.1
4-
category-encoders==2.2.2
4+
catboost>=1.0.1
5+
category-encoders>=2.2.2
56
dash-bootstrap-components==1.1.0
67
dash-core-components==2.0.0
78
dash-daq==0.5.0
89
dash-html-components==2.0.0
910
dash-renderer==1.8.3
1011
dash-table==5.0.0
1112
lightgbm==2.3.1
12-
numpy>1.18.0
1313
pandas>1.0.2
1414
plotly==5.6.0
15-
shap==0.38.1
15+
shap>=0.38.1
1616
Sphinx==4.5.0
1717
sphinxcontrib-applehelp==1.0.2
1818
sphinxcontrib-devhelp==1.0.2
@@ -22,19 +22,20 @@ sphinxcontrib-qthelp==1.0.3
2222
sphinxcontrib-serializinghtml==1.1.5
2323
nbsphinx==0.8.8
2424
sphinx_material==0.0.35
25-
pytest==5.2.3
26-
pytest-cov==2.8.1
27-
scikit-learn==0.24.2
25+
pytest>=6.2.5
26+
pytest-cov>=2.8.1
27+
scikit-learn>=0.24.2
2828
xgboost==1.0.0
2929
nbformat>4.2.0
30-
numba==0.53.1
30+
numba>=0.53.1
3131
nbconvert>=6.0.7
32-
papermill
33-
matplotlib
32+
papermill>=2.0.0
33+
matplotlib>=3.3.0
3434
seaborn==0.11.1
35-
notebook
36-
Jinja2>=2.11.0,<3.1.0
37-
phik
38-
acv-exp==1.1.2
39-
lime
40-
regex
35+
notebook>=6.0.0
36+
Jinja2>=2.11.0
37+
phik>=0.12.0
38+
skranger>=0.6.0
39+
acv-exp>=1.1.2
40+
lime>=0.2.0.0
41+
regex

setup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# This list should be identical to the list in shapash/report/__init__.py
4242
extras['report'] = [
4343
'nbconvert==6.0.7',
44-
'papermill',
44+
'papermill>=2.0.0',
4545
'seaborn<=0.11.2',
4646
'notebook',
4747
'Jinja2>=2.11.0,<3.1.0',
@@ -50,11 +50,11 @@
5050

5151
extras['xgboost'] = ['xgboost>=1.0.0']
5252
extras['lightgbm'] = ['lightgbm>=2.3.0']
53-
extras['catboost'] = ['catboost>=0.21']
53+
extras['catboost'] = ['catboost>=1.0.1']
5454
extras['scikit-learn'] = ['scikit-learn>=0.23.0']
5555
extras['category_encoders'] = ['category_encoders>=2.2.2']
56-
extras['acv'] = ['acv-exp==1.1.2']
57-
extras['lime'] = ['lime']
56+
extras['acv'] = ['acv-exp==1.2.0']
57+
extras['lime'] = ['lime>=0.2.0.0']
5858

5959
setup_requirements = ['pytest-runner', ]
6060

@@ -63,19 +63,19 @@
6363
setup(
6464
name="shapash",
6565
version=version_d['__version__'],
66-
python_requires='>3.5, <3.10',
66+
python_requires='>3.6, <3.11',
6767
url='https://github.com/MAIF/shapash',
6868
author="Yann Golhen, Sebastien Bidault, Yann Lagre, Maxime Gendre",
6969
author_email="[email protected]",
7070
description="Shapash is a Python library which aims to make machine learning interpretable and understandable by everyone.",
7171
long_description=long_description,
7272
long_description_content_type='text/markdown',
7373
classifiers=[
74-
"Programming Language :: Python :: 3",
75-
'Programming Language :: Python :: 3.6',
74+
"Programming Language :: Python :: 3",
7675
'Programming Language :: Python :: 3.7',
7776
'Programming Language :: Python :: 3.8',
7877
'Programming Language :: Python :: 3.9',
78+
'Programming Language :: Python :: 3.10',
7979
"License :: OSI Approved :: Apache Software License",
8080
"Operating System :: OS Independent",
8181
],

shapash/utils/columntransformer_backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ def get_col_mapping_ct(encoder, x_encoded):
465465
raise NotImplementedError(f'Estimator not supported : {estimator}')
466466

467467
elif estimator == 'passthrough':
468-
features_out = encoder._feature_names_in[features]
468+
try:
469+
features_out = encoder.feature_names_in_[features]
470+
except:
471+
features_out = encoder._feature_names_in[features] #for oldest sklearn version
469472
for f_name in features_out:
470473
dict_col_mapping[f_name] = [x_encoded.columns.to_list()[idx_encoded]]
471474
idx_encoded += 1
9.72 KB
Binary file not shown.

tests/unit_tests/explainer/test_smart_explainer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,15 +661,15 @@ def test_load_1(self):
661661
"""
662662
temp, xpl = init_sme_to_pickle_test()
663663

664-
current = Path(path.abspath(__file__)).parent.parent.parent
665-
if str(sys.version)[0:3] == '3.6':
666-
pkl_file = path.join(current, 'data/xpl_to_load_36.pkl')
667-
elif str(sys.version)[0:3] == '3.7':
664+
current = Path(path.abspath(__file__)).parent.parent.parent
665+
if str(sys.version)[0:3] == '3.7':
668666
pkl_file = path.join(current, 'data/xpl_to_load_37.pkl')
669667
elif str(sys.version)[0:3] == '3.8':
670668
pkl_file = path.join(current, 'data/xpl_to_load_38.pkl')
671669
elif str(sys.version)[0:3] == '3.9':
672670
pkl_file = path.join(current, 'data/xpl_to_load_39.pkl')
671+
elif str(sys.version)[0:4] == '3.10':
672+
pkl_file = path.join(current, 'data/xpl_to_load_310.pkl')
673673
else:
674674
raise NotImplementedError
675675

@@ -1152,7 +1152,7 @@ def test_generate_report(self, mock_execute_report, mock_export_and_save_report)
11521152
mock_export_and_save_report.assert_called_once()
11531153

11541154
def test_compute_features_stability_1(self):
1155-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
1155+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
11561156
selection = [1, 3]
11571157
X = df.iloc[:, :-1]
11581158
y = df.iloc[:, -1]
@@ -1168,7 +1168,7 @@ def test_compute_features_stability_1(self):
11681168
assert xpl.features_stability["amplitude"].shape == expected
11691169

11701170
def test_compute_features_stability_2(self):
1171-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
1171+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
11721172
selection = [1]
11731173
X = df.iloc[:, :-1]
11741174
y = df.iloc[:, -1]

tests/unit_tests/explainer/test_smart_plotter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ def test_correlations_2(self):
20642064

20652065
def test_stability_plot_1(self):
20662066
np.random.seed(42)
2067-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
2067+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
20682068
X = df.iloc[:, :-1]
20692069
y = df.iloc[:, -1]
20702070
model = DecisionTreeRegressor().fit(X, y)
@@ -2081,7 +2081,7 @@ def test_stability_plot_1(self):
20812081

20822082
def test_stability_plot_2(self):
20832083
np.random.seed(42)
2084-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
2084+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
20852085
X = df.iloc[:, :-1]
20862086
y = df.iloc[:, -1]
20872087
model = DecisionTreeRegressor().fit(X, y)
@@ -2101,7 +2101,7 @@ def test_stability_plot_2(self):
21012101
assert np.array(list(output.data[0].x)).dtype == "float"
21022102

21032103
def test_stability_plot_3(self):
2104-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
2104+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
21052105
X = df.iloc[:, :-1]
21062106
y = df.iloc[:, -1]
21072107
model = DecisionTreeRegressor().fit(X, y)
@@ -2120,7 +2120,7 @@ def test_stability_plot_3(self):
21202120
assert np.array(list(output.data[0].x)).dtype == "float"
21212121

21222122
def test_stability_plot_4(self):
2123-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
2123+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
21242124
X = df.iloc[:, :-1]
21252125
y = df.iloc[:, -1]
21262126
model = DecisionTreeRegressor().fit(X, y)
@@ -2140,7 +2140,7 @@ def test_stability_plot_4(self):
21402140
assert np.array(list(output.data[0].x)).dtype == "float"
21412141

21422142
def test_stability_plot_5(self):
2143-
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list('ABCD'))
2143+
df = pd.DataFrame(np.random.randint(1, 100, size=(15, 4)), columns=list('ABCD'))
21442144
X = df.iloc[:, :-1]
21452145
y = df.iloc[:, -1]
21462146
model = DecisionTreeRegressor().fit(X, y)

tests/unit_tests/utils/test_columntransformer_backend.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sklearn.compose import ColumnTransformer
99
import sklearn.preprocessing as skp
1010
import catboost as cb
11-
import sklearn
11+
import sklearn as sk
1212
import lightgbm
1313
import xgboost
1414
from shapash.utils.transform import inverse_transform
@@ -563,12 +563,19 @@ def test_inv_transform_ct_18(self):
563563
enc.fit(train, y)
564564
test = pd.DataFrame({'num1': [0, 1, 1],
565565
'num2': [0, 2, 3],
566-
'other': ['A', 'B', 'C']})
567-
568-
expected = pd.DataFrame({'std_num1': [0.0, 1.0, 1.0],
569-
'std_num2': [0.0, 2.0, 3.0],
570-
'other': ['A', 'B', 'C']},
571-
dtype=object)
566+
'other': ['A', 'B', 'C']},
567+
)
568+
if sk.__version__ >="1.0.0":
569+
expected = pd.DataFrame({'std_num1': [0.0, 1.0, 1.0],
570+
'std_num2': [0.0, 2.0, 3.0],
571+
'other': ['A', 'B', 'C']},
572+
)
573+
else:
574+
expected = pd.DataFrame({'std_num1': [0.0, 1.0, 1.0],
575+
'std_num2': [0.0, 2.0, 3.0],
576+
'other': ['A', 'B', 'C']},
577+
dtype=object
578+
)
572579

573580
result = pd.DataFrame(enc.transform(test))
574581
result.columns = ['col1', 'col2', 'other']

tests/unit_tests/utils/test_load_smartpredictor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ def test_load_smartpredictor_1(self):
2626
current = Path(path.abspath(__file__)).parent.parent.parent
2727
if str(sys.version)[0:3] == '3.7':
2828
pkl_file = path.join(current, 'data/predictor_to_load_37.pkl')
29-
elif str(sys.version)[0:3] == '3.6':
30-
pkl_file = path.join(current, 'data/predictor_to_load_36.pkl')
29+
elif str(sys.version)[0:4] == '3.10':
30+
pkl_file = path.join(current, 'data/predictor_to_load_310.pkl')
3131
elif str(sys.version)[0:3] == '3.8':
3232
pkl_file = path.join(current, 'data/predictor_to_load_38.pkl')
3333
elif str(sys.version)[0:3] == '3.9':
3434
pkl_file = path.join(current, 'data/predictor_to_load_39.pkl')
3535
else:
3636
raise NotImplementedError
3737

38+
predictor.save(pkl_file)
3839
predictor2 = load_smartpredictor(pkl_file)
3940

4041
attrib_predictor = [element for element in predictor.__dict__.keys()]

0 commit comments

Comments
 (0)