question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can Autosklearn be used with SHAP?

See original GitHub issue

Can the model be used with SHAP?

Currently

import shap
explainer = shap.Explainer(model)

results in

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-361-5c713ec694d6> in <module>
----> 1 explainer = shap.Explainer(model)

~/anaconda3/envs/python3/lib/python3.6/site-packages/shap/explainers/_explainer.py in __init__(self, model, masker, link, algorithm, output_names, feature_names, **kwargs)
    145                 # if we get here then we don't know how to handle what was given to us
    146                 else:
--> 147                     raise Exception("The passed model is not callable and cannot be analyzed directly with the given masker! Model: " + str(model))
    148 
    149             # build the right subclass

Exception: The passed model is not callable and cannot be analyzed directly with the given masker! Model: AutoSklearn2Classifier(delete_output_folder_after_terminate=False,
                       ensemble_size=1, memory_limit=7000, metric=f1, n_jobs=8,
                       output_folder='automl4_preds', per_run_time_limit=480,
                       time_left_for_this_task=600)

System Details (if relevant)

auto-sklearn 0.12.7 shap 0.38.1 Running on Linux?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mfeurercommented, Oct 29, 2021
1reaction
eddiebergmancommented, Oct 28, 2021

Hi @roger-yu-ds,

Looking at shap source code for Explainer.__init__(), it seems that it will not work out of the box as you have given.

I would suggest using their model agnostic Explainer.

estimator = AutoSklearnClassifier(...) 
explainer = shap.KernelExplainer(estimator.predict_proba, shap.sample(X_train, 128))

I would also advise updating auto-sklearn to 14.0 as we fixed some issues with probability outputs in some scenarios. Hopefully it won’t matter but if you face issues with incorrect probability sizes, this should fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

APIs — AutoSklearn 0.15.0 documentation
User-created dask client, can be used to start a dask cluster and then attach auto-sklearn ... List of str of len(X.shape[1]) describing the...
Read more >
Auto-Sklearn: Accelerate your machine learning models with ...
The main approach in Auto-Sklearn is to limit the involvement of data scientists and let the tool handle all time-consuming processes.
Read more >
Auto-Sklearn for Automated Machine Learning in Python
In this tutorial, you will discover how to use Auto-Sklearn for AutoML ... The example below downloads the dataset and summarizes its shape....
Read more >
Auto-Sklearn: AutoML in Python - ODSC - Open Data Science
Instead of manually specifying a pipeline, we can just use the Auto-sklearn estimator object and all that's left is to decide how much ......
Read more >
Complete Guide to Using AutoSklearn - Tool For Faster ...
Automated machine learning algorithms can be a huge time saver especially if the data is huge or the algorithm to be used is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found