Explainer Dashboard - Run an flask app inside a dash app

I’m currently building a App with a Dash Interface. One thing I’d like to introduce is a explainability tab for my machine learning models created inside the app. When searching how to show Shap-Values I stumbled upon the explainerdashboard library.

In order to safe a lot of time, I want to make a callback with my model-pipeline element and my data stored in the dcc.store object as input and have all the explainerdashboard tabs as output since it perfectly covers everything what I want to test and show.

Since I am already running an app with dash is there a way to include and show the explainerdashboard as output?
The deployment doesn’t show a way.
Link Deployment

Or is it possible to have the link to the explainerdashbord in a Div to open it in a new browser tab?

Thank you so much for your help, would appreciate if someone has experience with it!

1 Like

Hi,

I don’t have any experience with the library you mentioned, but it seems to me that this shouldn’t be hard, based on the documentation you provided. It is important to note that the Flask app object is in Dash.server, so you have to add the route to app.server instead of app.

From this section, I would say that you can make the following modifications (I haven’t tested it):

from dash import Dash

app = Dash(__name__)

# This is where the flask 'app' is in dash...
server = app.server

# [...]

db = ExplainerDashboard(explainer, server=server, url_base_pathname="/dashboard/")

# Define your app as usual...

# Add the endpoint to dash
@server.route('/dashboard')
def return_dashboard():
    return db.app.index()

If it does not work and you are able to provide a minimal example, I would be happy to take a look. Hope this helps!

2 Likes

Hi,

I’m struggling to do the same thing but under a multi page app with the structure described in dagster pages.

How should I proceed in such case when using dash.register_app()?

Thanksa lot in advance!

Hi,

I believe you would still be able to register new endpoints f. ex. in app.py. Just use @app.server.route() where app = dash.Dash(...).