Mercurial > repos > bgruening > sklearn_pairwise_metrics
annotate ml_visualization_ex.py @ 45:7614281473da draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5
author | bgruening |
---|---|
date | Sun, 05 Nov 2023 15:05:49 +0000 |
parents | e79200975daf |
children |
rev | line source |
---|---|
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
1 import argparse |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
2 import json |
36
cd4328a02798
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
35
diff
changeset
|
3 import os |
cd4328a02798
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
35
diff
changeset
|
4 import warnings |
cd4328a02798
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
35
diff
changeset
|
5 |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
6 import matplotlib |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
7 import matplotlib.pyplot as plt |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
8 import numpy as np |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
9 import pandas as pd |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
10 import plotly |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
11 import plotly.graph_objs as go |
41
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
12 from galaxy_ml.model_persist import load_model_from_h5 |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
13 from galaxy_ml.utils import read_columns, SafeEval |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
14 from sklearn.feature_selection._base import SelectorMixin |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
15 from sklearn.metrics import ( |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
16 auc, |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
17 average_precision_score, |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
18 confusion_matrix, |
41
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
19 precision_recall_curve, |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
20 roc_curve, |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
21 ) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
22 from sklearn.pipeline import Pipeline |
41
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
23 from tensorflow.keras.models import model_from_json |
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
24 from tensorflow.keras.utils import plot_model |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
25 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
26 safe_eval = SafeEval() |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
27 |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
28 # plotly default colors |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
29 default_colors = [ |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
30 "#1f77b4", # muted blue |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
31 "#ff7f0e", # safety orange |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
32 "#2ca02c", # cooked asparagus green |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
33 "#d62728", # brick red |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
34 "#9467bd", # muted purple |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
35 "#8c564b", # chestnut brown |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
36 "#e377c2", # raspberry yogurt pink |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
37 "#7f7f7f", # middle gray |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
38 "#bcbd22", # curry yellow-green |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
39 "#17becf", # blue-teal |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
40 ] |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
41 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
42 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
43 def visualize_pr_curve_plotly(df1, df2, pos_label, title=None): |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
44 """output pr-curve in html using plotly |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
45 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
46 df1 : pandas.DataFrame |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
47 Containing y_true |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
48 df2 : pandas.DataFrame |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
49 Containing y_score |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
50 pos_label : None |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
51 The label of positive class |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
52 title : str |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
53 Plot title |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
54 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
55 data = [] |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
56 for idx in range(df1.shape[1]): |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
57 y_true = df1.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
58 y_score = df2.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
59 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
60 precision, recall, _ = precision_recall_curve( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
61 y_true, y_score, pos_label=pos_label |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
62 ) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
63 ap = average_precision_score(y_true, y_score, pos_label=pos_label or 1) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
64 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
65 trace = go.Scatter( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
66 x=recall, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
67 y=precision, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
68 mode="lines", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
69 marker=dict(color=default_colors[idx % len(default_colors)]), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
70 name="%s (area = %.3f)" % (idx, ap), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
71 ) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
72 data.append(trace) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
73 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
74 layout = go.Layout( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
75 xaxis=dict(title="Recall", linecolor="lightslategray", linewidth=1), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
76 yaxis=dict(title="Precision", linecolor="lightslategray", linewidth=1), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
77 title=dict( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
78 text=title or "Precision-Recall Curve", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
79 x=0.5, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
80 y=0.92, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
81 xanchor="center", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
82 yanchor="top", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
83 ), |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
84 font=dict(family="sans-serif", size=11), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
85 # control backgroud colors |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
86 plot_bgcolor="rgba(255,255,255,0)", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
87 ) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
88 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
89 legend=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
90 x=0.95, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
91 y=0, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
92 traceorder="normal", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
93 font=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
94 family="sans-serif", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
95 size=9, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
96 color="black" |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
97 ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
98 bgcolor="LightSteelBlue", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
99 bordercolor="Black", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
100 borderwidth=2 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
101 ),""" |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
102 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
103 fig = go.Figure(data=data, layout=layout) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
104 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
105 plotly.offline.plot(fig, filename="output.html", auto_open=False) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
106 # to be discovered by `from_work_dir` |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
107 os.rename("output.html", "output") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
108 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
109 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
110 def visualize_pr_curve_matplotlib(df1, df2, pos_label, title=None): |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
111 """visualize pr-curve using matplotlib and output svg image""" |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
112 backend = matplotlib.get_backend() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
113 if "inline" not in backend: |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
114 matplotlib.use("SVG") |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
115 plt.style.use("seaborn-colorblind") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
116 plt.figure() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
117 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
118 for idx in range(df1.shape[1]): |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
119 y_true = df1.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
120 y_score = df2.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
121 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
122 precision, recall, _ = precision_recall_curve( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
123 y_true, y_score, pos_label=pos_label |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
124 ) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
125 ap = average_precision_score(y_true, y_score, pos_label=pos_label or 1) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
126 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
127 plt.step( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
128 recall, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
129 precision, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
130 "r-", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
131 color="black", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
132 alpha=0.3, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
133 lw=1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
134 where="post", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
135 label="%s (area = %.3f)" % (idx, ap), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
136 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
137 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
138 plt.xlim([0.0, 1.0]) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
139 plt.ylim([0.0, 1.05]) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
140 plt.xlabel("Recall") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
141 plt.ylabel("Precision") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
142 title = title or "Precision-Recall Curve" |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
143 plt.title(title) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
144 folder = os.getcwd() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
145 plt.savefig(os.path.join(folder, "output.svg"), format="svg") |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
146 os.rename(os.path.join(folder, "output.svg"), os.path.join(folder, "output")) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
147 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
148 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
149 def visualize_roc_curve_plotly(df1, df2, pos_label, drop_intermediate=True, title=None): |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
150 """output roc-curve in html using plotly |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
151 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
152 df1 : pandas.DataFrame |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
153 Containing y_true |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
154 df2 : pandas.DataFrame |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
155 Containing y_score |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
156 pos_label : None |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
157 The label of positive class |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
158 drop_intermediate : bool |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
159 Whether to drop some suboptimal thresholds |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
160 title : str |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
161 Plot title |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
162 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
163 data = [] |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
164 for idx in range(df1.shape[1]): |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
165 y_true = df1.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
166 y_score = df2.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
167 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
168 fpr, tpr, _ = roc_curve( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
169 y_true, y_score, pos_label=pos_label, drop_intermediate=drop_intermediate |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
170 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
171 roc_auc = auc(fpr, tpr) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
172 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
173 trace = go.Scatter( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
174 x=fpr, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
175 y=tpr, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
176 mode="lines", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
177 marker=dict(color=default_colors[idx % len(default_colors)]), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
178 name="%s (area = %.3f)" % (idx, roc_auc), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
179 ) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
180 data.append(trace) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
181 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
182 layout = go.Layout( |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
183 xaxis=dict( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
184 title="False Positive Rate", linecolor="lightslategray", linewidth=1 |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
185 ), |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
186 yaxis=dict(title="True Positive Rate", linecolor="lightslategray", linewidth=1), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
187 title=dict( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
188 text=title or "Receiver Operating Characteristic (ROC) Curve", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
189 x=0.5, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
190 y=0.92, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
191 xanchor="center", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
192 yanchor="top", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
193 ), |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
194 font=dict(family="sans-serif", size=11), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
195 # control backgroud colors |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
196 plot_bgcolor="rgba(255,255,255,0)", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
197 ) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
198 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
199 # legend=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
200 # x=0.95, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
201 # y=0, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
202 # traceorder="normal", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
203 # font=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
204 # family="sans-serif", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
205 # size=9, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
206 # color="black" |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
207 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
208 # bgcolor="LightSteelBlue", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
209 # bordercolor="Black", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
210 # borderwidth=2 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
211 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
212 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
213 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
214 fig = go.Figure(data=data, layout=layout) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
215 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
216 plotly.offline.plot(fig, filename="output.html", auto_open=False) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
217 # to be discovered by `from_work_dir` |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
218 os.rename("output.html", "output") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
219 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
220 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
221 def visualize_roc_curve_matplotlib( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
222 df1, df2, pos_label, drop_intermediate=True, title=None |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
223 ): |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
224 """visualize roc-curve using matplotlib and output svg image""" |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
225 backend = matplotlib.get_backend() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
226 if "inline" not in backend: |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
227 matplotlib.use("SVG") |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
228 plt.style.use("seaborn-colorblind") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
229 plt.figure() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
230 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
231 for idx in range(df1.shape[1]): |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
232 y_true = df1.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
233 y_score = df2.iloc[:, idx].values |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
234 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
235 fpr, tpr, _ = roc_curve( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
236 y_true, y_score, pos_label=pos_label, drop_intermediate=drop_intermediate |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
237 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
238 roc_auc = auc(fpr, tpr) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
239 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
240 plt.step( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
241 fpr, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
242 tpr, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
243 "r-", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
244 color="black", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
245 alpha=0.3, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
246 lw=1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
247 where="post", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
248 label="%s (area = %.3f)" % (idx, roc_auc), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
249 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
250 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
251 plt.xlim([0.0, 1.0]) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
252 plt.ylim([0.0, 1.05]) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
253 plt.xlabel("False Positive Rate") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
254 plt.ylabel("True Positive Rate") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
255 title = title or "Receiver Operating Characteristic (ROC) Curve" |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
256 plt.title(title) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
257 folder = os.getcwd() |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
258 plt.savefig(os.path.join(folder, "output.svg"), format="svg") |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
259 os.rename(os.path.join(folder, "output.svg"), os.path.join(folder, "output")) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
260 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
261 |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
262 def get_dataframe(file_path, plot_selection, header_name, column_name): |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
263 header = "infer" if plot_selection[header_name] else None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
264 column_option = plot_selection[column_name]["selected_column_selector_option"] |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
265 if column_option in [ |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
266 "by_index_number", |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
267 "all_but_by_index_number", |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
268 "by_header_name", |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
269 "all_but_by_header_name", |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
270 ]: |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
271 col = plot_selection[column_name]["col1"] |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
272 else: |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
273 col = None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
274 _, input_df = read_columns( |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
275 file_path, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
276 c=col, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
277 c_option=column_option, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
278 return_df=True, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
279 sep="\t", |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
280 header=header, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
281 parse_dates=True, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
282 ) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
283 return input_df |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
284 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
285 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
286 def main( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
287 inputs, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
288 infile_estimator=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
289 infile1=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
290 infile2=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
291 outfile_result=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
292 outfile_object=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
293 groups=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
294 ref_seq=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
295 intervals=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
296 targets=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
297 fasta_path=None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
298 model_config=None, |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
299 true_labels=None, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
300 predicted_labels=None, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
301 plot_color=None, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
302 title=None, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
303 ): |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
304 """ |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
305 Parameter |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
306 --------- |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
307 inputs : str |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
308 File path to galaxy tool parameter |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
309 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
310 infile_estimator : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
311 File path to estimator |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
312 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
313 infile1 : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
314 File path to dataset containing features or true labels. |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
315 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
316 infile2 : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
317 File path to dataset containing target values or predicted |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
318 probabilities. |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
319 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
320 outfile_result : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
321 File path to save the results, either cv_results or test result |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
322 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
323 outfile_object : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
324 File path to save searchCV object |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
325 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
326 groups : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
327 File path to dataset containing groups labels |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
328 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
329 ref_seq : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
330 File path to dataset containing genome sequence file |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
331 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
332 intervals : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
333 File path to dataset containing interval file |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
334 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
335 targets : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
336 File path to dataset compressed target bed file |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
337 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
338 fasta_path : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
339 File path to dataset containing fasta file |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
340 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
341 model_config : str, default is None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
342 File path to dataset containing JSON config for neural networks |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
343 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
344 true_labels : str, default is None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
345 File path to dataset containing true labels |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
346 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
347 predicted_labels : str, default is None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
348 File path to dataset containing true predicted labels |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
349 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
350 plot_color : str, default is None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
351 Color of the confusion matrix heatmap |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
352 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
353 title : str, default is None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
354 Title of the confusion matrix heatmap |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
355 """ |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
356 warnings.simplefilter("ignore") |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
357 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
358 with open(inputs, "r") as param_handler: |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
359 params = json.load(param_handler) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
360 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
361 title = params["plotting_selection"]["title"].strip() |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
362 plot_type = params["plotting_selection"]["plot_type"] |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
363 plot_format = params["plotting_selection"]["plot_format"] |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
364 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
365 if plot_type == "feature_importances": |
41
053e7f32d37e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
37
diff
changeset
|
366 estimator = load_model_from_h5(infile_estimator) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
367 |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
368 column_option = params["plotting_selection"]["column_selector_options"][ |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
369 "selected_column_selector_option" |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
370 ] |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
371 if column_option in [ |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
372 "by_index_number", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
373 "all_but_by_index_number", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
374 "by_header_name", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
375 "all_but_by_header_name", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
376 ]: |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
377 c = params["plotting_selection"]["column_selector_options"]["col1"] |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
378 else: |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
379 c = None |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
380 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
381 _, input_df = read_columns( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
382 infile1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
383 c=c, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
384 c_option=column_option, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
385 return_df=True, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
386 sep="\t", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
387 header="infer", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
388 parse_dates=True, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
389 ) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
390 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
391 feature_names = input_df.columns.values |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
392 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
393 if isinstance(estimator, Pipeline): |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
394 for st in estimator.steps[:-1]: |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
395 if isinstance(st[-1], SelectorMixin): |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
396 mask = st[-1].get_support() |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
397 feature_names = feature_names[mask] |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
398 estimator = estimator.steps[-1][-1] |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
399 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
400 if hasattr(estimator, "coef_"): |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
401 coefs = estimator.coef_ |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
402 else: |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
403 coefs = getattr(estimator, "feature_importances_", None) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
404 if coefs is None: |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
405 raise RuntimeError( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
406 "The classifier does not expose " |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
407 '"coef_" or "feature_importances_" ' |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
408 "attributes" |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
409 ) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
410 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
411 threshold = params["plotting_selection"]["threshold"] |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
412 if threshold is not None: |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
413 mask = (coefs > threshold) | (coefs < -threshold) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
414 coefs = coefs[mask] |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
415 feature_names = feature_names[mask] |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
416 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
417 # sort |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
418 indices = np.argsort(coefs)[::-1] |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
419 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
420 trace = go.Bar(x=feature_names[indices], y=coefs[indices]) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
421 layout = go.Layout(title=title or "Feature Importances") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
422 fig = go.Figure(data=[trace], layout=layout) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
423 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
424 plotly.offline.plot(fig, filename="output.html", auto_open=False) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
425 # to be discovered by `from_work_dir` |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
426 os.rename("output.html", "output") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
427 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
428 return 0 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
429 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
430 elif plot_type in ("pr_curve", "roc_curve"): |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
431 df1 = pd.read_csv(infile1, sep="\t", header="infer") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
432 df2 = pd.read_csv(infile2, sep="\t", header="infer").astype(np.float32) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
433 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
434 minimum = params["plotting_selection"]["report_minimum_n_positives"] |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
435 # filter out columns whose n_positives is beblow the threhold |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
436 if minimum: |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
437 mask = df1.sum(axis=0) >= minimum |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
438 df1 = df1.loc[:, mask] |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
439 df2 = df2.loc[:, mask] |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
440 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
441 pos_label = params["plotting_selection"]["pos_label"].strip() or None |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
442 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
443 if plot_type == "pr_curve": |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
444 if plot_format == "plotly_html": |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
445 visualize_pr_curve_plotly(df1, df2, pos_label, title=title) |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
446 else: |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
447 visualize_pr_curve_matplotlib(df1, df2, pos_label, title) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
448 else: # 'roc_curve' |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
449 drop_intermediate = params["plotting_selection"]["drop_intermediate"] |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
450 if plot_format == "plotly_html": |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
451 visualize_roc_curve_plotly( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
452 df1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
453 df2, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
454 pos_label, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
455 drop_intermediate=drop_intermediate, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
456 title=title, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
457 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
458 else: |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
459 visualize_roc_curve_matplotlib( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
460 df1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
461 df2, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
462 pos_label, |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
463 drop_intermediate=drop_intermediate, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
464 title=title, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
465 ) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
466 |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
467 return 0 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
468 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
469 elif plot_type == "rfecv_gridscores": |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
470 input_df = pd.read_csv(infile1, sep="\t", header="infer") |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
471 scores = input_df.iloc[:, 0] |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
472 steps = params["plotting_selection"]["steps"].strip() |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
473 steps = safe_eval(steps) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
474 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
475 data = go.Scatter( |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
476 x=list(range(len(scores))), |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
477 y=scores, |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
478 text=[str(_) for _ in steps] if steps else None, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
479 mode="lines", |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
480 ) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
481 layout = go.Layout( |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
482 xaxis=dict(title="Number of features selected"), |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
483 yaxis=dict(title="Cross validation score"), |
37
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
484 title=dict( |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
485 text=title or None, x=0.5, y=0.92, xanchor="center", yanchor="top" |
09bfbef3dd90
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
36
diff
changeset
|
486 ), |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
487 font=dict(family="sans-serif", size=11), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
488 # control backgroud colors |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
489 plot_bgcolor="rgba(255,255,255,0)", |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
490 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
491 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
492 # legend=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
493 # x=0.95, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
494 # y=0, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
495 # traceorder="normal", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
496 # font=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
497 # family="sans-serif", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
498 # size=9, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
499 # color="black" |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
500 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
501 # bgcolor="LightSteelBlue", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
502 # bordercolor="Black", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
503 # borderwidth=2 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
504 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
505 """ |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
506 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
507 fig = go.Figure(data=[data], layout=layout) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
508 plotly.offline.plot(fig, filename="output.html", auto_open=False) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
509 # to be discovered by `from_work_dir` |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
510 os.rename("output.html", "output") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
511 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
512 return 0 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
513 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
514 elif plot_type == "learning_curve": |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
515 input_df = pd.read_csv(infile1, sep="\t", header="infer") |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
516 plot_std_err = params["plotting_selection"]["plot_std_err"] |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
517 data1 = go.Scatter( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
518 x=input_df["train_sizes_abs"], |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
519 y=input_df["mean_train_scores"], |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
520 error_y=dict(array=input_df["std_train_scores"]) if plot_std_err else None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
521 mode="lines", |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
522 name="Train Scores", |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
523 ) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
524 data2 = go.Scatter( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
525 x=input_df["train_sizes_abs"], |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
526 y=input_df["mean_test_scores"], |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
527 error_y=dict(array=input_df["std_test_scores"]) if plot_std_err else None, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
528 mode="lines", |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
529 name="Test Scores", |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
530 ) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
531 layout = dict( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
532 xaxis=dict(title="No. of samples"), |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
533 yaxis=dict(title="Performance Score"), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
534 # modify these configurations to customize image |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
535 title=dict( |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
536 text=title or "Learning Curve", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
537 x=0.5, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
538 y=0.92, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
539 xanchor="center", |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
540 yanchor="top", |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
541 ), |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
542 font=dict(family="sans-serif", size=11), |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
543 # control backgroud colors |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
544 plot_bgcolor="rgba(255,255,255,0)", |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
545 ) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
546 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
547 # legend=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
548 # x=0.95, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
549 # y=0, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
550 # traceorder="normal", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
551 # font=dict( |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
552 # family="sans-serif", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
553 # size=9, |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
554 # color="black" |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
555 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
556 # bgcolor="LightSteelBlue", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
557 # bordercolor="Black", |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
558 # borderwidth=2 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
559 # ), |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
560 """ |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
561 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
562 fig = go.Figure(data=[data1, data2], layout=layout) |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
563 plotly.offline.plot(fig, filename="output.html", auto_open=False) |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
564 # to be discovered by `from_work_dir` |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
565 os.rename("output.html", "output") |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
566 |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
567 return 0 |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
568 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
569 elif plot_type == "keras_plot_model": |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
570 with open(model_config, "r") as f: |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
571 model_str = f.read() |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
572 model = model_from_json(model_str) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
573 plot_model(model, to_file="output.png") |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
574 os.rename("output.png", "output") |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
575 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
576 return 0 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
577 |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
578 elif plot_type == "classification_confusion_matrix": |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
579 plot_selection = params["plotting_selection"] |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
580 input_true = get_dataframe( |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
581 true_labels, plot_selection, "header_true", "column_selector_options_true" |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
582 ) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
583 header_predicted = "infer" if plot_selection["header_predicted"] else None |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
584 input_predicted = pd.read_csv( |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
585 predicted_labels, sep="\t", parse_dates=True, header=header_predicted |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
586 ) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
587 true_classes = input_true.iloc[:, -1].copy() |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
588 predicted_classes = input_predicted.iloc[:, -1].copy() |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
589 axis_labels = list(set(true_classes)) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
590 c_matrix = confusion_matrix(true_classes, predicted_classes) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
591 fig, ax = plt.subplots(figsize=(7, 7)) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
592 im = plt.imshow(c_matrix, cmap=plot_color) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
593 for i in range(len(c_matrix)): |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
594 for j in range(len(c_matrix)): |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
595 ax.text(j, i, c_matrix[i, j], ha="center", va="center", color="k") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
596 ax.set_ylabel("True class labels") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
597 ax.set_xlabel("Predicted class labels") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
598 ax.set_title(title) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
599 ax.set_xticks(axis_labels) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
600 ax.set_yticks(axis_labels) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
601 fig.colorbar(im, ax=ax) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
602 fig.tight_layout() |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
603 plt.savefig("output.png", dpi=125) |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
604 os.rename("output.png", "output") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
605 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
606 return 0 |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
607 |
31
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
608 # save pdf file to disk |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
609 # fig.write_image("image.pdf", format='pdf') |
bc17040617c0
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
28
diff
changeset
|
610 # fig.write_image("image.pdf", format='pdf', width=340*2, height=226*2) |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
611 |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
612 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
613 if __name__ == "__main__": |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
614 aparser = argparse.ArgumentParser() |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
615 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
616 aparser.add_argument("-e", "--estimator", dest="infile_estimator") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
617 aparser.add_argument("-X", "--infile1", dest="infile1") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
618 aparser.add_argument("-y", "--infile2", dest="infile2") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
619 aparser.add_argument("-O", "--outfile_result", dest="outfile_result") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
620 aparser.add_argument("-o", "--outfile_object", dest="outfile_object") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
621 aparser.add_argument("-g", "--groups", dest="groups") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
622 aparser.add_argument("-r", "--ref_seq", dest="ref_seq") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
623 aparser.add_argument("-b", "--intervals", dest="intervals") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
624 aparser.add_argument("-t", "--targets", dest="targets") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
625 aparser.add_argument("-f", "--fasta_path", dest="fasta_path") |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
626 aparser.add_argument("-c", "--model_config", dest="model_config") |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
627 aparser.add_argument("-tl", "--true_labels", dest="true_labels") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
628 aparser.add_argument("-pl", "--predicted_labels", dest="predicted_labels") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
629 aparser.add_argument("-pc", "--plot_color", dest="plot_color") |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
630 aparser.add_argument("-pt", "--title", dest="title") |
27
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
631 args = aparser.parse_args() |
20b7295ae6e9
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ba6a47bdf76bbf4cb276206ac1a8cbf61332fd16"
bgruening
parents:
diff
changeset
|
632 |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
633 main( |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
634 args.inputs, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
635 args.infile_estimator, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
636 args.infile1, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
637 args.infile2, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
638 args.outfile_result, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
639 outfile_object=args.outfile_object, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
640 groups=args.groups, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
641 ref_seq=args.ref_seq, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
642 intervals=args.intervals, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
643 targets=args.targets, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
644 fasta_path=args.fasta_path, |
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
645 model_config=args.model_config, |
42
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
646 true_labels=args.true_labels, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
647 predicted_labels=args.predicted_labels, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
648 plot_color=args.plot_color, |
e79200975daf
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 3c1e6c72303cfd8a5fd014734f18402b97f8ecb5
bgruening
parents:
41
diff
changeset
|
649 title=args.title, |
35
dbbe397b64ad
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
33
diff
changeset
|
650 ) |