Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogluon and explainerdashboard integration #270

Open
apavlo89 opened this issue Jun 14, 2023 · 4 comments
Open

Autogluon and explainerdashboard integration #270

apavlo89 opened this issue Jun 14, 2023 · 4 comments

Comments

@apavlo89
Copy link

Is there a way to load autogluon models into explainer dashboard?

@oegedijk
Copy link
Owner

I have never tried! As long as they are sklearn compatible and work with shap it should work I guess!

@AlexanderZender
Copy link

AlexanderZender commented Jul 7, 2023

If this is still of interest, I managed to make AutoGluon work with explainer dashboard. I used the most recent releases of both.

You need to wrap the model into a wrapper class that changes the predict_proba function, as the default result of Autogluon is different of what explainer dashboard expects:

  import numpy as np
  
  class AutoGluonWrapper:
  
      def __init__(self, model) -> None:
          self.__model = model
  
      def predict(self, x, **kwargs):
          self.__model.predict(x=x, **kwargs)
  
      def predict_proba(self, x, **kwargs):
          
          probabilities_raw = self.__model.predict_proba(x, **kwargs)
          probabilities = np.array(probabilities_raw)
          return probabilities

Then you can just call the dashboard using a training AutoGluon model:

dashboard = ExplainerDashboard(ClassifierExplainer(AutoGluonWrapper(model), X_test, y_test))

@oegedijk
Copy link
Owner

oegedijk commented Jul 8, 2023

wait, so the issue is that predict_proba doesn't return an np.ndarray by default? That should be easy enough to wrap or detect inside the library

@AlexanderZender
Copy link

Indeed, that is the issue with this AutoML, most AutoML actually work out of the box or with a simple wrapper class similar to the one I posted above.
In case a wrapper is needed, it is because the predict_proba returns something unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants