annotate dashboard.py @ 0:1bc26b9636d2 draft default tip

planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
author goeckslab
date Wed, 11 Dec 2024 03:29:00 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
1 import logging
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
2 from typing import Any, Dict, Optional
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
3
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
4 from pycaret.utils.generic import get_label_encoder
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
5
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
6 logging.basicConfig(level=logging.DEBUG)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
7 LOG = logging.getLogger(__name__)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
8
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
9
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
10 def generate_classifier_explainer_dashboard(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
11 exp,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
12 estimator,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
13 display_format: str = "dash",
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
14 dashboard_kwargs: Optional[Dict[str, Any]] = None,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
15 run_kwargs: Optional[Dict[str, Any]] = None,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
16 **kwargs,):
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
17
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
18 """
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
19 This function is changed from pycaret.classification.oop.dashboard()
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
20
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
21 This function generates the interactive dashboard for a trained model.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
22 The dashboard is implemented using
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
23 ExplainerDashboard (explainerdashboard.readthedocs.io)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
24
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
25
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
26 estimator: scikit-learn compatible object
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
27 Trained model object
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
28
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
29
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
30 display_format: str, default = 'dash'
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
31 Render mode for the dashboard. The default is set to ``dash``
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
32 which will
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
33 render a dashboard in browser. There are four possible options:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
34
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
35 - 'dash' - displays the dashboard in browser
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
36 - 'inline' - displays the dashboard in the jupyter notebook cell.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
37 - 'jupyterlab' - displays the dashboard in jupyterlab pane.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
38 - 'external' - displays the dashboard in a separate tab.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
39 (use in Colab)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
40
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
41
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
42 dashboard_kwargs: dict, default = {} (empty dict)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
43 Dictionary of arguments passed to the ``ExplainerDashboard`` class.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
44
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
45
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
46 run_kwargs: dict, default = {} (empty dict)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
47 Dictionary of arguments passed to the ``run``
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
48 method of ``ExplainerDashboard``.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
49
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
50
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
51 **kwargs:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
52 Additional keyword arguments to pass to the ``ClassifierExplainer``
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
53 or ``RegressionExplainer`` class.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
54
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
55
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
56 Returns:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
57 ExplainerDashboard
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
58 """
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
59
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
60 dashboard_kwargs = dashboard_kwargs or {}
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
61 run_kwargs = run_kwargs or {}
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
62
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
63 from explainerdashboard import ClassifierExplainer, ExplainerDashboard
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
64
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
65 le = get_label_encoder(exp.pipeline)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
66 if le:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
67 labels_ = list(le.classes_)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
68 else:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
69 labels_ = None
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
70
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
71 # Replaceing chars which dash doesnt accept for column name `.` , `{`, `}`
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
72
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
73 X_test_df = exp.X_test_transformed.copy()
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
74 LOG.info(X_test_df)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
75 X_test_df.columns = [
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
76 col.replace(".", "__").replace("{", "__").replace("}", "__")
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
77 for col in X_test_df.columns
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
78 ]
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
79
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
80 explainer = ClassifierExplainer(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
81 estimator, X_test_df, exp.y_test_transformed, labels=labels_, **kwargs
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
82 )
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
83 return ExplainerDashboard(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
84 explainer, mode=display_format,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
85 contributions=False, whatif=False,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
86 **dashboard_kwargs
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
87 )
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
88
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
89
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
90 def generate_regression_explainer_dashboard(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
91 exp,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
92 estimator,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
93 display_format: str = "dash",
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
94 dashboard_kwargs: Optional[Dict[str, Any]] = None,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
95 run_kwargs: Optional[Dict[str, Any]] = None,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
96 **kwargs,):
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
97
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
98 """
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
99 This function is changed from pycaret.regression.oop.dashboard()
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
100
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
101 This function generates the interactive dashboard for a trained model.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
102 The dashboard is implemented using ExplainerDashboard
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
103 (explainerdashboard.readthedocs.io)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
104
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
105
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
106 estimator: scikit-learn compatible object
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
107 Trained model object
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
108
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
109
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
110 display_format: str, default = 'dash'
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
111 Render mode for the dashboard. The default is set to ``dash``
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
112 which will
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
113 render a dashboard in browser. There are four possible options:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
114
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
115 - 'dash' - displays the dashboard in browser
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
116 - 'inline' - displays the dashboard in the jupyter notebook cell.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
117 - 'jupyterlab' - displays the dashboard in jupyterlab pane.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
118 - 'external' - displays the dashboard in a separate tab.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
119 (use in Colab)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
120
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
121
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
122 dashboard_kwargs: dict, default = {} (empty dict)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
123 Dictionary of arguments passed to the ``ExplainerDashboard`` class.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
124
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
125
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
126 run_kwargs: dict, default = {} (empty dict)
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
127 Dictionary of arguments passed to the ``run`` method
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
128 of ``ExplainerDashboard``.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
129
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
130
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
131 **kwargs:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
132 Additional keyword arguments to pass to the
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
133 ``ClassifierExplainer`` or
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
134 ``RegressionExplainer`` class.
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
135
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
136
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
137 Returns:
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
138 ExplainerDashboard
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
139 """
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
140
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
141 dashboard_kwargs = dashboard_kwargs or {}
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
142 run_kwargs = run_kwargs or {}
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
143
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
144 from explainerdashboard import ExplainerDashboard, RegressionExplainer
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
145
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
146 # Replaceing chars which dash doesnt accept for column name `.` , `{`, `}`
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
147 X_test_df = exp.X_test_transformed.copy()
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
148 X_test_df.columns = [
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
149 col.replace(".", "__").replace("{", "__").replace("}", "__")
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
150 for col in X_test_df.columns
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
151 ]
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
152 explainer = RegressionExplainer(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
153 estimator, X_test_df, exp.y_test_transformed, **kwargs
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
154 )
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
155 return ExplainerDashboard(
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
156 explainer, mode=display_format, contributions=False,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
157 whatif=False, shap_interaction=False, decision_trees=False,
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
158 **dashboard_kwargs
1bc26b9636d2 planemo upload for repository https://github.com/goeckslab/Galaxy-Pycaret commit 5089a5dffc154c8202624cfbd5f1be0f36a9f0cc
goeckslab
parents:
diff changeset
159 )