Skip to content

Commit f5bd4a5

Browse files
authored
Merge pull request #99 from oegedijk/dev
v0.3.3
2 parents 4a4aa57 + d0f7a91 commit f5bd4a5

13 files changed

Lines changed: 797 additions & 356 deletions

RELEASE_NOTES.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,44 @@
11
# Release Notes
2+
## Version 0.3.3:
3+
4+
Highlights:
5+
* Adding support for cross validated metrics
6+
* Better support for pipelines by using kernel explainer
7+
* Making explainer threadsafe by adding locks
8+
* Remove outliers from shap dependence plots
9+
10+
### Breaking Changes
11+
- parameter `permutation_cv` has been deprecated and replaced by parameter `cv` which
12+
now also works to calculate cross-validated metrics besides cross-validated
13+
permutation importances.
14+
15+
### New Features
16+
- metrics now get calculated with cross validation over `X` when you pass the
17+
`cv` parameter to the explainer, this is useful when for some reason you
18+
want to pass the training set to the explainer.
19+
- adds winsorization to shap dependence and shap interaction plots
20+
- If `shap='guess'` fails (unable to guess the right type of shap explainer),
21+
then default to the model agnostic `shap='kernel'`.
22+
- Better support for sklearn `Pipelines`: if not able to extract transformer+model,
23+
then default to `shap.KernelExplainer` to explain the entire pipeline
24+
- you can now remove outliers from shap dependence/interaction plots with
25+
`remove_outliers=True`: filters all outliers beyond 1.5*IQR
26+
27+
### Bug Fixes
28+
- Sets proper `threading.Locks` before making calls to shap explainer to prevent race
29+
conditions with dashboards calling for shap values in multiple threads.
30+
(shap is unfortunately not threadsafe)
31+
-
32+
33+
### Improvements
34+
- single shap row KernelExplainer calculations now go without tqdm progress bar
35+
- added cutoff tpr anf fpr to roc auc plot
36+
- added cutoff precision and recall to pr auc plot
37+
- put a loading spinner on shap contrib table
38+
39+
### Other Changes
40+
-
41+
-
242

343

444
## Version 0.3.2.2:
@@ -12,7 +52,7 @@
1252
### Bug Fixes
1353
- bug fix to make `shap.KernelExplainer` (used with explainer parameter`shap='kernel'`)
1454
work with `RegressionExplainer`
15-
- bug fix when no explicit `labels` are passed with index selector
55+
- bug fix when no explicit `labels` are based with index selector
1656
- component only update if `explainer.index_exists()`: no `IndexNotFoundErrors` anymore.
1757
- fixed title for regression index selector labeled 'Custom' bug
1858
- `get_y()` now returns `.item()` when necessary

TODO.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
## Plots:
88
- add SHAP decision plots:
99
https://towardsdatascience.com/introducing-shap-decision-plots-52ed3b4a1cba
10-
- add winsor to shap dependence
1110
- make plot background transparent?
1211
- Only use ScatterGl above a certain cutoff
1312
- seperate standard shap plots for shap_interaction plots
@@ -24,6 +23,7 @@
2423
### Regression plots:
2524

2625
## Explainers:
26+
- Turn print statements into logging
2727
- pass n_jobs to pdp_isolate
2828
- add ExtraTrees and GradientBoostingClassifier to tree visualizers
2929
- add plain language explanations
@@ -37,6 +37,7 @@
3737

3838

3939
## Dashboard:
40+
- Turn print statements into logging
4041
- make poweredby right align
4142
- more flexible instantiate_component:
4243
- no explainer needed (if explainer component detected, pass otherwise ignore)
@@ -59,7 +60,7 @@
5960

6061

6162
### Components
62-
- add winsor to shap dependence
63+
- add feature descriptions component
6364
- add predictions list to whatif composite:
6465
- https://github.com/oegedijk/explainerdashboard/issues/85
6566
- add circular callbacks to cutoff - cutoff percentile
@@ -86,6 +87,7 @@
8687
- Add this method? : https://arxiv.org/abs/2006.04750?
8788

8889
## Tests:
90+
- add cv metrics tests
8991
- add tests for InterpretML EBM (shap 0.37)
9092
- write tests for explainerhub CLI add user
9193
- test model_output='probability' and 'raw' or 'logodds' seperately

docs/source/explainers.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,15 @@ An example of using setting ``X_background`` and ``model_output`` with a
233233
ExplainerDashboard(explainer).run()
234234

235235

236-
permutation_cv
237-
--------------
236+
cv
237+
--
238+
239+
Normally metrics and permutation importances get calculated over a single fold
240+
(assuming the data ``X`` is the test set). However if you pass the training set
241+
to the explainer, you may wish to cross-validate calculate the permutation
242+
importances and metrics. In that case pass the number of folds to ``cv``.
243+
Note that custom metrics do not work with cross validation for now.
238244

239-
Normally permutation importances get calculated over a single fold (assuming the
240-
data is the test set). However if you pass the training set to the explainer,
241-
you may wish to cross-validate calculate the permutation importances. In that
242-
case pass the number of folds to ``permutation_cv``.
243245

244246
na_fill
245247
-------
@@ -505,7 +507,7 @@ get_importances_df
505507
.. automethod:: explainerdashboard.explainers.BaseExplainer.get_importances_df
506508

507509
get_contrib_df
508-
^^^^^^^^^^
510+
^^^^^^^^^^^^^^
509511

510512
.. automethod:: explainerdashboard.explainers.BaseExplainer.get_contrib_df
511513

@@ -614,12 +616,12 @@ with the following additional methods::
614616

615617

616618
get_decisionpath_df
617-
^^^^^^^^^^^^^^^
619+
^^^^^^^^^^^^^^^^^^^
618620

619621
.. automethod:: explainerdashboard.explainers.RandomForestExplainer.get_decisionpath_df
620622

621623
get_decisionpath_summary_df
622-
^^^^^^^^^^^^^^^^^^^^^^^
624+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
623625

624626
.. automethod:: explainerdashboard.explainers.RandomForestExplainer.get_decisionpath_summary_df
625627

explainerdashboard/dashboard_components/classifier_components.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ def update_output_div(index, pos_label):
357357
preds_df = self.explainer.prediction_result_df(index, round=self.round, logodds=True)
358358
preds_df.probability = np.round(100*preds_df.probability.values, self.round).astype(str)
359359
preds_df.probability = preds_df.probability + ' %'
360-
preds_df.logodds = np.round(preds_df.logodds.values, self.round).astype(str)
360+
if 'logodds' in preds_df.columns:
361+
preds_df.logodds = np.round(preds_df.logodds.values, self.round).astype(str)
361362

362-
if self.explainer.model_output!='logodds':
363+
if self.explainer.model_output != 'logodds':
363364
preds_df = preds_df[['label', 'probability']]
364365

365366
preds_table = dbc.Table.from_dataframe(preds_df,
@@ -379,7 +380,8 @@ def update_output_div(pos_label, *inputs):
379380
preds_df = self.explainer.prediction_result_df(X_row=X_row, round=self.round, logodds=True)
380381
preds_df.probability = np.round(100*preds_df.probability.values, self.round).astype(str)
381382
preds_df.probability = preds_df.probability + ' %'
382-
preds_df.logodds = np.round(preds_df.logodds.values, self.round).astype(str)
383+
if 'logodds' in preds_df.columns:
384+
preds_df.logodds = np.round(preds_df.logodds.values, self.round).astype(str)
383385

384386
if self.explainer.model_output!='logodds':
385387
preds_df = preds_df[['label', 'probability']]
@@ -527,7 +529,8 @@ def layout(self):
527529
marks={0.01: '0.01', 0.25: '0.25', 0.50: '0.50',
528530
0.75: '0.75', 0.99: '0.99'},
529531
included=False,
530-
tooltip = {'always_visible' : False}),
532+
tooltip = {'always_visible' : False},
533+
updatemode='drag'),
531534
], id='precision-cutoff-div-'+self.name),
532535
dbc.Tooltip(f"Scores above this cutoff will be labeled positive",
533536
target='precision-cutoff-div-'+self.name,

0 commit comments

Comments
 (0)