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