-
Notifications
You must be signed in to change notification settings - Fork 5
/
dashboard.py
executable file
·92 lines (67 loc) · 3.05 KB
/
dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# xgboost is a dependency of dtreeviz, but too large (>350M) for heroku
# so we uninstall it and mock it here:
from unittest.mock import MagicMock
import sys
sys.modules["xgboost"] = MagicMock()
from pathlib import Path
from flask import Flask
import dash
from dash_bootstrap_components.themes import FLATLY, BOOTSTRAP # bootstrap theme
from explainerdashboard import *
from index_layout import index_layout, register_callbacks
from custom import CustomModelTab, CustomPredictionsTab
pkl_dir = Path.cwd() / "pkls"
app = Flask(__name__)
clas_explainer = ClassifierExplainer.from_file(pkl_dir / "clas_explainer.joblib")
clas_dashboard = ExplainerDashboard(clas_explainer,
title="Classifier Explainer: Predicting survival on the Titanic",
server=app, url_base_pathname="/classifier/",
header_hide_selector=True)
reg_explainer = RegressionExplainer.from_file(pkl_dir / "reg_explainer.joblib")
reg_dashboard = ExplainerDashboard(reg_explainer,
title="Regression Explainer: Predicting ticket fare",
server=app, url_base_pathname="/regression/")
multi_explainer = ClassifierExplainer.from_file(pkl_dir / "multi_explainer.joblib")
multi_dashboard = ExplainerDashboard(multi_explainer,
title="Multiclass Explainer: Predicting departure port",
server=app, url_base_pathname="/multiclass/")
custom_dashboard = ExplainerDashboard(clas_explainer,
[CustomModelTab, CustomPredictionsTab],
title='Titanic Explainer', header_hide_selector=True,
bootstrap=FLATLY,
server=app, url_base_pathname="/custom/")
simple_classifier_dashboard = ExplainerDashboard(clas_explainer,
title="Simplified Classifier Dashboard", simple=True,
server=app, url_base_pathname="/simple_classifier/")
simple_regression_dashboard = ExplainerDashboard(reg_explainer,
title="Simplified Classifier Dashboard", simple=True,
server=app, url_base_pathname="/simple_regression/")
index_app = dash.Dash(
__name__,
server=app,
url_base_pathname="/",
external_stylesheets=[BOOTSTRAP])
index_app.title = 'explainerdashboard'
index_app.layout = index_layout
register_callbacks(index_app)
@app.route("/")
def index():
return index_app.index()
@app.route('/classifier')
def classifier_dashboard():
return clas_dashboard.app.index()
@app.route('/regression')
def regression_dashboard():
return reg_dashboard.app.index()
@app.route('/multiclass')
def multiclass_dashboard():
return multi_dashboard.app.index()
@app.route('/custom')
def custom_dashboard():
return custom_dashboard.app.index()
@app.route('/simple_classifier')
def simple_classifier_dashboard():
return simple_classifier_dashboard.app.index()
@app.route('/simple_regression')
def simple_regression_dashboard():
return simple_regression_dashboard.app.index()