Skip to content

Commit 2d8c536

Browse files
authored
Merge pull request #206 from ThibaudReal/feature/extras_requirements
Feature/extras requirements
2 parents 21e160c + 7f6e308 commit 2d8c536

File tree

14 files changed

+146
-38
lines changed

14 files changed

+146
-38
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
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]
11+
python-version: [3.6, 3.7, 3.8, 3.9]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Set up Python ${{ matrix.python-version }}

README.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@
3030
</a>
3131
</p>
3232

33+
## 🎉 What's new ?
34+
35+
| Version | New Feature | Description | Tutorial |
36+
|:-------------:|:-------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------:|:--------:|
37+
| 1.4.x | Groups of features <br> [demo]() | You can now regroup features that share common properties together. <br>This option can be useful if your model has a lot of features. | [<img src="https://raw.githubusercontent.com/MAIF/shapash/master/docs/_static/groups_features.gif" width="120" title="groups-features">](https://github.com/MAIF/shapash/blob/master/tutorial/common/tuto-common01-groups_of_features.ipynb) |
38+
| 1.3.x | Shapash Report <br> [demo](https://shapash.readthedocs.io/en/latest/report.html) | A standalone HTML report that constitutes a basis of an audit document. | [<img src="https://raw.githubusercontent.com/MAIF/shapash/master/docs/_static/report-icon.png" width="8%" title="shapash-report">](https://github.com/MAIF/shapash/blob/master/tutorial/report/tuto-shapash-report01.ipynb) |
3339

34-
🎉 **We just released Shapash 1.3.2 that includes the generation of a standalone HTML report that constitutes a basis of an audit document. [See an example here](https://shapash.readthedocs.io/en/latest/report.html) that was generated [using this tutorial.](https://github.com/MAIF/shapash/blob/master/tutorial/report/tuto-shapash-report01.ipynb)** 🎉
3540

3641
## 🔍 Overview
3742

@@ -44,18 +49,22 @@ Shapash also contributes to data science auditing by displaying usefull informat
4449

4550
- Readthedocs: [![documentation badge](https://readthedocs.org/projects/shapash/badge/?version=latest)](https://shapash.readthedocs.io/en/latest/)
4651
- [Presentation video for french speakers](https://www.youtube.com/watch?v=r1R_A9B9apk)
47-
- Medium:
48-
<a href="https://www.kdnuggets.com/2021/04/shapash-machine-learning-models-understandable.html">
49-
<p align="center">
50-
<img align="left" src="https://www.kdnuggets.com/images/tkb-2104-g.png?raw=true" width="6%" />
51-
</p>
52-
</a>
52+
- Medium:
53+
- [Understand your model with Shapash - Towards AI](https://pub.towardsai.net/shapash-making-ml-models-understandable-by-everyone-8f96ad469eb3)
54+
- [Model auditability - Towards DS](https://towardsdatascience.com/shapash-1-3-2-announcing-new-features-for-more-auditable-ai-64a6db71c919)
55+
56+
## 🏆 Awards
57+
58+
<a href="https://raw.githubusercontent.com/MAIF/shapash/master/docs/_static/awards-argus-or.png">
59+
<img align="left" src="https://raw.githubusercontent.com/MAIF/shapash/master/docs/_static/awards-argus-or.png" width="130" />
60+
</a>
5361

62+
<a href="https://www.kdnuggets.com/2021/04/shapash-machine-learning-models-understandable.html">
63+
<img src="https://www.kdnuggets.com/images/tkb-2104-g.png?raw=true" width="50" />
64+
</a>
5465

55-
- [Understand your model with Shapash - Towards AI](https://pub.towardsai.net/shapash-making-ml-models-understandable-by-everyone-8f96ad469eb3)
56-
- [Model auditability - Towards DS](https://towardsdatascience.com/shapash-1-3-2-announcing-new-features-for-more-auditable-ai-64a6db71c919)
5766

58-
## 🔥 Features
67+
## 🔥 Features
5968

6069
- Display clear and understandable results: plots and outputs use **explicit labels** for each feature and its values
6170

@@ -66,9 +75,9 @@ Shapash also contributes to data science auditing by displaying usefull informat
6675
</p>
6776

6877
<p align="center">
69-
<img align="left" src="https://github.com/MAIF/shapash/blob/master/docs/_static/shapash-grid-images-07.png?raw=true" width="28%" />
78+
<img align="left" src="https://github.com/MAIF/shapash/blob/master/docs/_static/shapash-grid-images-01.png?raw=true" width="28%" />
7079
<img src="https://github.com/MAIF/shapash/blob/master/docs/_static/shapash-resize.png?raw=true" width="18%" />
71-
<img align="right" src="https://github.com/MAIF/shapash/blob/master/docs/_static/shapash-grid-images-01.png?raw=true" width="28%" />
80+
<img align="right" src="https://github.com/MAIF/shapash/blob/master/docs/_static/shapash-grid-images-09.png?raw=true" width="28%" />
7281
</p>
7382

7483
<p align="center">
@@ -117,12 +126,20 @@ to compute contributions.
117126

118127
## 🛠 Installation
119128

120-
Shapash is intended to work with Python versions 3.6 to 3.8. Installation can be done with pip:
129+
Shapash is intended to work with Python versions 3.6 to 3.9. Installation can be done with pip:
121130

122131
```
123132
pip install shapash
124133
```
125134

135+
In order to generate the Shapash Report some extra requirements are needed.
136+
You can install these using the following command :
137+
```
138+
pip install shapash[report]
139+
```
140+
141+
If you encounter **compatibility issues** you may check the corresponding section in the Shapash documentation [here](https://shapash.readthedocs.io/en/latest/installation-instructions/index.html).
142+
126143
## 🕐 Quickstart
127144

128145
The 4 steps to display results:
@@ -195,6 +212,7 @@ This github repository offers a lot of tutorials to allow you to start more conc
195212
- [Launch the webapp with a concrete use case](tutorial/tutorial01-Shapash-Overview-Launch-WebApp.ipynb)
196213
- [Jupyter Overviews - The main outputs and methods available with the SmartExplainer object](tutorial/tutorial02-Shapash-overview-in-Jupyter.ipynb)
197214
- [Shapash in production: From model training to deployment (API or Batch Mode)](tutorial/tutorial03-Shapash-overview-model-in-production.ipynb)
215+
- [Use groups of features](tutorial/common/tuto-common01-groups_of_features.ipynb)
198216

199217
### More details about charts and plots
200218
- [**Shapash** Features Importance](tutorial/plot/tuto-plot03-features-importance.ipynb)

docs/_static/awards-argus-or.png

26.8 KB
Loading

docs/_static/groups_features.gif

8.8 KB
Loading

docs/_static/report-icon.png

27 KB
Loading

docs/installation-instructions/index.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ Installation instructions
44
Installing
55
----------
66

7-
Users can install **Shapash** with pip:
7+
**Shapash** is intended to work with Python versions 3.6 to 3.9. Installation can be done with pip:
88

99
.. code:: bash
1010
1111
pip install shapash
1212
13+
14+
In order to generate the **Shapash Report** you may need to install specific libraries.
15+
You can install these using the following command :
16+
17+
.. code:: bash
18+
19+
pip install shapash[report]
20+
1321
Jupyter
1422
-------
1523

@@ -213,3 +221,24 @@ To test if plotly works:
213221
214222
.. image:: plotly.png
215223

224+
225+
Compatibility issues
226+
--------------------
227+
228+
When using Shapash, you may encounter some compatibility issues related to your environment and the libraries' versions used.
229+
The extras requirements of Shapash allow you to update your requirements to a compatible version.
230+
231+
For example, if you get an error related to the *xgboost* library, you can use the following command to update it to a working version :
232+
233+
.. code:: bash
234+
235+
pip install shapash[xgboost]
236+
237+
The full list of extras requirements is listed below (replace xgboost with the corresponding library on the command above) :
238+
239+
* xgboost
240+
* lightgbm
241+
* catboost
242+
* scikit-learn
243+
* category_encoders
244+

requirements.dev.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pip==20.2.4
22
dash==1.17.0
3-
catboost==0.22
3+
catboost>=0.22
44
category-encoders==2.1.0
55
dash-bootstrap-components==0.9.1
66
dash-core-components==1.13.0
@@ -23,12 +23,14 @@ sphinxcontrib-qthelp==1.0.3
2323
sphinxcontrib-serializinghtml==1.1.4
2424
pytest==5.2.3
2525
pytest-cov==2.8.1
26-
scikit-learn==0.23.2
26+
scikit-learn>=0.23.2
2727
xgboost==1.0.0
2828
nbformat>4.2.0
29-
numba==0.51.2
29+
numba==0.53.1
3030
nbconvert==6.0.7
31-
papermill==2.3.2
32-
matplotlib==3.3.4
33-
seaborn==0.11.1
34-
jupyter==1.0.0
31+
papermill
32+
matplotlib
33+
seaborn
34+
notebook
35+
Jinja2
36+
phik

setup.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'plotly==4.12.0',
1313
'numpy>1.18.0',
1414
'pandas>1.0.2',
15-
'shap==0.37.0',
15+
'shap>=0.36.0',
1616
'dash==1.17.0',
1717
'dash-bootstrap-components==0.9.1',
1818
'dash-core-components==1.13.0',
@@ -21,21 +21,37 @@
2121
'dash-renderer==1.8.3',
2222
'dash-table==4.11.0',
2323
'nbformat>4.2.0',
24-
'numba==0.51.2',
25-
'nbconvert==6.0.7',
26-
'papermill==2.3.2',
27-
'matplotlib>=3.0',
28-
'seaborn==0.11.1'
24+
'numba==0.53.1',
25+
'scikit-learn'
2926
]
3027

28+
extras = dict()
29+
30+
# This list should be identical to the list in shapash/report/__init__.py
31+
extras['report'] = [
32+
'nbconvert==6.0.7',
33+
'papermill',
34+
'matplotlib',
35+
'seaborn',
36+
'notebook',
37+
'Jinja2',
38+
'phik'
39+
]
40+
41+
extras['xgboost'] = ['xgboost>=1.0.0']
42+
extras['lightgbm'] = ['lightgbm>=2.3.0']
43+
extras['catboost'] = ['catboost>=0.21']
44+
extras['scikit-learn'] = ['scikit-learn>=0.23.0']
45+
extras['category_encoders'] = ['category_encoders==2.2.2']
46+
3147
setup_requirements = ['pytest-runner', ]
3248

3349
test_requirements = ['pytest', ]
3450

3551
setup(
36-
name="shapash", # Replace with your own username
52+
name="shapash",
3753
version="1.3.2",
38-
python_requires='>3.5, < 3.9',
54+
python_requires='>3.5, <=3.9',
3955
url='https://github.com/MAIF/shapash',
4056
author="Yann Golhen, Sebastien Bidault, Yann Lagre, Maxime Gendre",
4157
author_email="[email protected]",
@@ -51,6 +67,7 @@
5167
"Operating System :: OS Independent",
5268
],
5369
install_requires=requirements,
70+
extras_require=extras,
5471
license="Apache Software License 2.0",
5572
keywords='shapash',
5673
package_dir={

shapash/explainer/smart_explainer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from shapash.utils.check import check_model, check_label_dict, check_ypred, check_contribution_object,\
1818
check_postprocessing, check_features_name
1919
from shapash.manipulation.select_lines import keep_right_contributions
20+
from shapash.report import check_report_requirements
2021
from shapash.manipulation.summarize import create_grouped_features_values
21-
from shapash.report.generation import execute_report, export_and_save_report
2222
from .smart_state import SmartState
2323
from .multi_decorator import MultiDecorator
2424
from .smart_plotter import SmartPlotter
@@ -1179,6 +1179,10 @@ def generate_report(self,
11791179
]
11801180
)
11811181
"""
1182+
check_report_requirements()
1183+
# Avoid Import Errors with requirements specific to the Shapash Report
1184+
from shapash.report.generation import execute_report, export_and_save_report
1185+
11821186
rm_working_dir = False
11831187
if not working_dir:
11841188
working_dir = tempfile.mkdtemp()

shapash/report/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import importlib
2+
3+
# This list should be identical to the list in setup.py
4+
report_requirements = [
5+
'nbconvert==6.0.7',
6+
'papermill',
7+
'matplotlib',
8+
'seaborn',
9+
'notebook',
10+
'Jinja2'
11+
]
12+
13+
14+
def check_report_requirements():
15+
"""
16+
Checks that all required packages for the report are installed.
17+
This function should be called before executing the report.
18+
"""
19+
for req in report_requirements:
20+
pkg = req.split('=')[0]
21+
try:
22+
importlib.import_module(pkg.lower())
23+
except (ModuleNotFoundError, ImportError):
24+
raise ModuleNotFoundError(f"The following package is necessary to generate the Shapash Report : {pkg}. "
25+
f"Try 'pip install shapash[report]' to install all required packages.")

0 commit comments

Comments
 (0)