Skip to content

Commit

Permalink
adds options to specify hub explainer dump type
Browse files Browse the repository at this point in the history
previous behaviour was to default to .joblib, can now
specify .dill or .pkl instead.
  • Loading branch information
oegedijk committed Dec 24, 2021
1 parent dfbf9bb commit bdd03da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

- add get_descriptions_df tests
- do multiclass pdp
- add manual add shap values functionality

- experiment with dash_draggable: https://github.com/MehdiChelh/dash-draggable
- add ExplainerHub.to_html()
- add set_shap_values tests
- add hub.to_yaml() dashboard dump option, e.g. 'joblib', 'dill' or 'pkl'
- add how to create `ExplainerComponent` to docs (see closed issue)
## Bugs:

## Plots:
Expand Down
6 changes: 4 additions & 2 deletions explainerdashboard/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ def convert_db(db, filepath=None):
return cls(dashboards, **update_kwargs(config, **update_params))

def to_yaml(self, filepath:Path=None, dump_explainers=True,
return_dict=False, integrate_dashboard_yamls=False):
return_dict=False, integrate_dashboard_yamls=False, pickle_type="joblib"):
"""Store ExplainerHub to configuration .yaml, store the users to users.json
and dump the underlying dashboard .yamls and explainers.
Expand All @@ -1347,6 +1347,8 @@ def to_yaml(self, filepath:Path=None, dump_explainers=True,
separate_dashboard_yamls=True. Defaults to False.
integrate_dashboard_yamls(bool, optional): Do not generate an individual
.yaml file for each dashboard, but integrate them in hub.yaml.
pickle_type ({'joblib', 'dill', 'pkl'}, optional). Format to dump explainers in.
Defaults to "joblib". Alternatives are "dill" and "pkl".
Returns:
{dict, yaml, None}
Expand All @@ -1368,7 +1370,7 @@ def to_yaml(self, filepath:Path=None, dump_explainers=True,
for dashboard in self.dashboards:
print(f"Storing {dashboard.name}_dashboard.yaml...")
dashboard.to_yaml(filepath.parent / (dashboard.name+"_dashboard.yaml"),
explainerfile=filepath.parent / (dashboard.name+"_explainer.joblib"),
explainerfile=filepath.parent / (dashboard.name+f"_explainer.{pickle_type}"),
dump_explainer=dump_explainers)
hub_config = dict(
explainerhub=dict(
Expand Down
3 changes: 2 additions & 1 deletion explainerdashboard/explainer_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def guess_shap(model):

skorch_models = ['skorch.net.NeuralNet',
'skorch.regressor.NeuralNetRegressor',
'skorch.classifier.NeuralNetClassifier']
'skorch.classifier.NeuralNetClassifier',
'skorch.classifier.NeuralNetBinaryClassifier']

for tree_model in tree_models:
if str(type(model)).endswith(tree_model + "'>"):
Expand Down

0 comments on commit bdd03da

Please sign in to comment.