Skip to content

Commit 25e3c57

Browse files
authored
FAI-952: Change dependencies to align with ODH workbench images (#143)
* Change dependencies to align with ODH workbench images * Deprecate Python 3.7 * Replace Bokeh with jupyter_bokeh * Replace XGBoost model with scikit-learn * Use correct dev dependencies in CI * Replace pytest-xdist with pytest-forked (Not all xdist features needed, just fork)
1 parent 148e419 commit 25e3c57

File tree

9 files changed

+34
-54
lines changed

9 files changed

+34
-54
lines changed

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [ 3.7, 3.8, 3.9 ]
10+
python-version: [ 3.8, 3.9 ]
1111
java-version: [ 11, 17 ]
1212
maven-version: [ '3.8.6' ]
1313
steps:
@@ -25,8 +25,8 @@ jobs:
2525
uses: ./.github/actions/build-core
2626
- name: Install TrustyAI Python package
2727
run: |
28-
pip install -r requirements-dev.txt
2928
pip install .
29+
pip install ".[dev]"
3030
- name: Lint
3131
run: |
3232
pylint --ignore-imports=yes $(find src/trustyai -type f -name "*.py")

pyproject.toml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Python bindings to the TrustyAI explainability library."
55
authors = [{ name = "Rui Vieira", email = "rui@redhat.com" }]
66
license = { file = "LICENSE" }
77
readme = "README.md"
8-
requires-python = ">=3.7"
8+
requires-python = ">=3.8"
99

1010
keywords = ["trustyai", "xai", "explainability", "ml"]
1111

@@ -23,32 +23,30 @@ classifiers = [
2323
dependencies = [
2424
"Jpype1==1.4.1",
2525
"pyarrow==7.0.0",
26-
"matplotlib==3.5.1",
27-
"pandas==1.2.5",
28-
"numpy",
29-
"bokeh==2.4.3"
26+
"matplotlib~=3.6.3",
27+
"pandas~=1.5.3",
28+
"numpy~=1.24.1",
29+
"jupyter-bokeh~=3.0.5"
3030
]
3131

3232
[project.optional-dependencies]
3333
dev = [
3434
"JPype1==1.4.1",
35-
"black==21.6b0",
35+
"black~=22.12.0",
3636
"click==8.0.4",
37-
"joblib==1.0.1",
38-
"jupyter==1.0.0",
39-
"scikit-learn==0.24.2",
37+
"joblib~=1.2.0",
38+
"jupyterlab~=3.5.3",
39+
"numpydoc==1.5.0",
40+
"pyarrow==7.0.0",
4041
"pylint==2.15.6",
41-
"pytest==6.2.4",
42+
"pytest~=7.2.1",
43+
"pytest-benchmark==4.0.0",
44+
"pytest-forked~=1.6.0",
45+
"scikit-learn~=1.2.1",
4246
"setuptools",
43-
"wheel",
44-
"xgboost==1.4.2",
4547
"twine==3.4.2",
46-
"pyarrow==7.0.0",
47-
"numpydoc",
48-
"matplotlib==3.5.1",
49-
"pandas==1.2.5",
50-
"pytest-xdist",
51-
"pytest-benchmark"
48+
"wheel~=0.38.4",
49+
"xgboost==1.4.2"
5250
]
5351

5452
[project.urls]

requirements-dev.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/trustyai/explainers/lime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _get_bokeh_plot(self, output_name) -> bokeh.models.Plot:
191191
)
192192
source = ColumnDataSource(lime_data_source)
193193
htool = HoverTool(
194-
names=["bars"],
194+
name="bars",
195195
tooltips="<h3>LIME</h3> {} saliency to {}: @saliency_colored".format(
196196
feature_html("@feature"), output_html(output_name)
197197
),

src/trustyai/explainers/shap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,21 @@ def _get_bokeh_plot(self, output_name):
295295

296296
# create hovertools
297297
htool_fnull = HoverTool(
298-
names=["fnull"],
298+
name="fnull",
299299
tooltips=("<h3>SHAP</h3>Baseline {}: {}").format(
300300
output_name, output_html("{:.2f}".format(fnull))
301301
),
302302
line_policy="interp",
303303
)
304304
htool_pred = HoverTool(
305-
names=["pred"],
305+
name="pred",
306306
tooltips=("<h3>SHAP</h3>Predicted {}: {}").format(
307307
output_name, output_html("{:.2f}".format(prediction))
308308
),
309309
line_policy="interp",
310310
)
311311
htool_bars = HoverTool(
312-
names=["bars"],
312+
name="bars",
313313
tooltips="<h3>SHAP</h3> {} contributions to {}: @saliency_text".format(
314314
feature_html("@feature"), output_html(output_name)
315315
),

src/trustyai/utils/tyrus.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
LinearColorMapper,
1515
ColorBar,
1616
Tabs,
17-
Panel,
17+
TabPanel,
1818
Div,
1919
GridBox,
2020
)
@@ -324,17 +324,17 @@ def _get_plots(self):
324324
title = str(k)
325325
lime_tabbed = Tabs(
326326
tabs=[
327-
Panel(child=lime_figures[k], title="LIME"),
328-
Panel(
327+
TabPanel(child=lime_figures[k], title="LIME"),
328+
TabPanel(
329329
child=Div(text=LIME_TEXT.format(output_html(title))),
330330
title="About LIME",
331331
),
332332
]
333333
)
334334
shap_tabbed = Tabs(
335335
tabs=[
336-
Panel(child=shap_figures[k], title="SHAP"),
337-
Panel(
336+
TabPanel(child=shap_figures[k], title="SHAP"),
337+
TabPanel(
338338
child=Div(text=SHAP_TEXT.format(output_html(title))),
339339
title="About SHAP",
340340
),
@@ -343,8 +343,8 @@ def _get_plots(self):
343343

344344
cf_tabbed = Tabs(
345345
tabs=[
346-
Panel(child=cf_figures[k], title="Available Counterfactuals"),
347-
Panel(
346+
TabPanel(child=cf_figures[k], title="Available Counterfactuals"),
347+
TabPanel(
348348
child=Div(
349349
text=CF_TEXT.format(output_html(title)),
350350
),
@@ -369,7 +369,7 @@ def _get_plots(self):
369369
trustyai_content,
370370
sizing_mode="scale_width",
371371
)
372-
tabs.append(Panel(child=joint, title=title))
372+
tabs.append(TabPanel(child=joint, title=title))
373373

374374
full_dash = Tabs(tabs=tabs, sizing_mode="scale_width")
375375
return full_dash
-402 KB
Binary file not shown.
14 MB
Binary file not shown.

tests/general/test_group_fairness.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
from pytest import approx
88
import pandas as pd
9-
from xgboost import XGBClassifier
9+
from sklearn.ensemble import RandomForestClassifier
1010
import os
11+
import joblib
1112
import pathlib
1213

1314
from trustyai.metrics.fairness.group import statistical_parity_difference, disparate_impact_ratio, \
@@ -23,8 +24,8 @@
2324
INCOME_DF_BIASED = pd.read_csv(os.path.join(TEST_DIR, "data/income-biased.zip"), index_col=False)
2425
INCOME_DF_UNBIASED = pd.read_csv(
2526
os.path.join(TEST_DIR, "data/income-unbiased.zip"), index_col=False)
26-
XGB_MODEL = XGBClassifier()
27-
XGB_MODEL.load_model(os.path.join(TEST_DIR, "models/income-xgb-biased.ubj"))
27+
28+
XGB_MODEL = joblib.load(os.path.join(TEST_DIR, "models/income-xgd-biased.joblib"))
2829

2930

3031
def test_statistical_parity_difference_random():

0 commit comments

Comments
 (0)