Mercurial > repos > bgruening > sklearn_train_test_eval
annotate keras_train_and_eval.py @ 18:ddc4fe317a92 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
author | bgruening |
---|---|
date | Mon, 02 Oct 2023 10:28:18 +0000 |
parents | 2eb5c017958d |
children | f12383ee3234 |
rev | line source |
---|---|
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
1 import argparse |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
2 import json |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
3 import os |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
4 import warnings |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
5 from itertools import chain |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
6 |
10
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
7 import joblib |
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
8 import numpy as np |
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
9 import pandas as pd |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
10 from galaxy_ml.keras_galaxy_models import ( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
11 _predict_generator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
12 KerasGBatchClassifier, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
13 ) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
14 from galaxy_ml.model_persist import dump_model_to_h5, load_model_from_h5 |
10
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
15 from galaxy_ml.model_validations import train_test_split |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
16 from galaxy_ml.utils import ( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
17 clean_params, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
18 gen_compute_scores, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
19 get_main_estimator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
20 get_module, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
21 get_scoring, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
22 read_columns, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
23 SafeEval |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
24 ) |
10
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
25 from scipy.io import mmread |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
26 from sklearn.metrics._scorer import _check_multimetric_scoring |
10
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
27 from sklearn.model_selection._validation import _score |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
28 from sklearn.utils import _safe_indexing, indexable |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
29 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
30 N_JOBS = int(os.environ.get("GALAXY_SLOTS", 1)) |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
31 CACHE_DIR = os.path.join(os.getcwd(), "cached") |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
32 NON_SEARCHABLE = ( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
33 "n_jobs", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
34 "pre_dispatch", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
35 "memory", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
36 "_path", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
37 "_dir", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
38 "nthread", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
39 "callbacks", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
40 ) |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
41 ALLOWED_CALLBACKS = ( |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
42 "EarlyStopping", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
43 "TerminateOnNaN", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
44 "ReduceLROnPlateau", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
45 "CSVLogger", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
46 "None", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
47 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
48 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
49 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
50 def _eval_swap_params(params_builder): |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
51 swap_params = {} |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
52 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
53 for p in params_builder["param_set"]: |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
54 swap_value = p["sp_value"].strip() |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
55 if swap_value == "": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
56 continue |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
57 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
58 param_name = p["sp_name"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
59 if param_name.lower().endswith(NON_SEARCHABLE): |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
60 warnings.warn( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
61 "Warning: `%s` is not eligible for search and was " |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
62 "omitted!" % param_name |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
63 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
64 continue |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
65 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
66 if not swap_value.startswith(":"): |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
67 safe_eval = SafeEval(load_scipy=True, load_numpy=True) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
68 ev = safe_eval(swap_value) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
69 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
70 # Have `:` before search list, asks for estimator evaluatio |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
71 safe_eval_es = SafeEval(load_estimators=True) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
72 swap_value = swap_value[1:].strip() |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
73 # TODO maybe add regular express check |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
74 ev = safe_eval_es(swap_value) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
75 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
76 swap_params[param_name] = ev |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
77 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
78 return swap_params |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
79 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
80 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
81 def train_test_split_none(*arrays, **kwargs): |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
82 """extend train_test_split to take None arrays |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
83 and support split by group names. |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
84 """ |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
85 nones = [] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
86 new_arrays = [] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
87 for idx, arr in enumerate(arrays): |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
88 if arr is None: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
89 nones.append(idx) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
90 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
91 new_arrays.append(arr) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
92 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
93 if kwargs["shuffle"] == "None": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
94 kwargs["shuffle"] = None |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
95 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
96 group_names = kwargs.pop("group_names", None) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
97 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
98 if group_names is not None and group_names.strip(): |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
99 group_names = [name.strip() for name in group_names.split(",")] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
100 new_arrays = indexable(*new_arrays) |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
101 groups = kwargs["labels"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
102 n_samples = new_arrays[0].shape[0] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
103 index_arr = np.arange(n_samples) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
104 test = index_arr[np.isin(groups, group_names)] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
105 train = index_arr[~np.isin(groups, group_names)] |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
106 rval = list( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
107 chain.from_iterable( |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
108 (_safe_indexing(a, train), _safe_indexing(a, test)) for a in new_arrays |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
109 ) |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
110 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
111 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
112 rval = train_test_split(*new_arrays, **kwargs) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
113 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
114 for pos in nones: |
10
a9e0b963b7bb
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
bgruening
parents:
9
diff
changeset
|
115 rval[pos * 2: 2] = [None, None] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
116 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
117 return rval |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
118 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
119 |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
120 def _evaluate_keras_and_sklearn_scores( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
121 estimator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
122 data_generator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
123 X, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
124 y=None, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
125 sk_scoring=None, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
126 steps=None, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
127 batch_size=32, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
128 return_predictions=False, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
129 ): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
130 """output scores for bother keras and sklearn metrics |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
131 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
132 Parameters |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
133 ----------- |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
134 estimator : object |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
135 Fitted `galaxy_ml.keras_galaxy_models.KerasGBatchClassifier`. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
136 data_generator : object |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
137 From `galaxy_ml.preprocessors.ImageDataFrameBatchGenerator`. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
138 X : 2-D array |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
139 Contains indecies of images that need to be evaluated. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
140 y : None |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
141 Target value. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
142 sk_scoring : dict |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
143 Galaxy tool input parameters. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
144 steps : integer or None |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
145 Evaluation/prediction steps before stop. |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
146 batch_size : integer |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
147 Number of samples in a batch |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
148 return_predictions : bool, default is False |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
149 Whether to return predictions and true labels. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
150 """ |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
151 scores = {} |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
152 |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
153 generator = data_generator.flow(X, y=y, batch_size=batch_size) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
154 # keras metrics evaluation |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
155 # handle scorer, convert to scorer dict |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
156 generator.reset() |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
157 score_results = estimator.model_.evaluate_generator(generator, steps=steps) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
158 metrics_names = estimator.model_.metrics_names |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
159 if not isinstance(metrics_names, list): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
160 scores[metrics_names] = score_results |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
161 else: |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
162 scores = dict(zip(metrics_names, score_results)) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
163 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
164 if sk_scoring["primary_scoring"] == "default" and not return_predictions: |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
165 return scores |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
166 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
167 generator.reset() |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
168 predictions, y_true = _predict_generator(estimator.model_, generator, steps=steps) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
169 |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
170 # for sklearn metrics |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
171 if sk_scoring["primary_scoring"] != "default": |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
172 scorer = get_scoring(sk_scoring) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
173 if not isinstance(scorer, (dict, list)): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
174 scorer = [sk_scoring["primary_scoring"]] |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
175 scorer = _check_multimetric_scoring(estimator, scoring=scorer) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
176 sk_scores = gen_compute_scores(y_true, predictions, scorer) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
177 scores.update(sk_scores) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
178 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
179 if return_predictions: |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
180 return scores, predictions, y_true |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
181 else: |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
182 return scores, None, None |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
183 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
184 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
185 def main( |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
186 inputs, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
187 infile_estimator, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
188 infile1, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
189 infile2, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
190 outfile_result, |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
191 outfile_history=None, |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
192 outfile_object=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
193 outfile_y_true=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
194 outfile_y_preds=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
195 groups=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
196 ref_seq=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
197 intervals=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
198 targets=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
199 fasta_path=None, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
200 ): |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
201 """ |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
202 Parameter |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
203 --------- |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
204 inputs : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
205 File path to galaxy tool parameter. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
206 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
207 infile_estimator : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
208 File path to estimator. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
209 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
210 infile1 : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
211 File path to dataset containing features. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
212 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
213 infile2 : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
214 File path to dataset containing target values. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
215 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
216 outfile_result : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
217 File path to save the results, either cv_results or test result. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
218 |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
219 outfile_history : str, optional |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
220 File path to save the training history. |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
221 |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
222 outfile_object : str, optional |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
223 File path to save searchCV object. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
224 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
225 outfile_y_true : str, optional |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
226 File path to target values for prediction. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
227 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
228 outfile_y_preds : str, optional |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
229 File path to save predictions. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
230 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
231 groups : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
232 File path to dataset containing groups labels. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
233 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
234 ref_seq : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
235 File path to dataset containing genome sequence file. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
236 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
237 intervals : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
238 File path to dataset containing interval file. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
239 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
240 targets : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
241 File path to dataset compressed target bed file. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
242 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
243 fasta_path : str |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
244 File path to dataset containing fasta file. |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
245 """ |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
246 warnings.simplefilter("ignore") |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
247 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
248 with open(inputs, "r") as param_handler: |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
249 params = json.load(param_handler) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
250 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
251 # load estimator |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
252 estimator = load_model_from_h5(infile_estimator) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
253 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
254 estimator = clean_params(estimator) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
255 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
256 # swap hyperparameter |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
257 swapping = params["experiment_schemes"]["hyperparams_swapping"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
258 swap_params = _eval_swap_params(swapping) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
259 estimator.set_params(**swap_params) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
260 estimator_params = estimator.get_params() |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
261 # store read dataframe object |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
262 loaded_df = {} |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
263 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
264 input_type = params["input_options"]["selected_input"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
265 # tabular input |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
266 if input_type == "tabular": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
267 header = "infer" if params["input_options"]["header1"] else None |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
268 column_option = params["input_options"]["column_selector_options_1"][ |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
269 "selected_column_selector_option" |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
270 ] |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
271 if column_option in [ |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
272 "by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
273 "all_but_by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
274 "by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
275 "all_but_by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
276 ]: |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
277 c = params["input_options"]["column_selector_options_1"]["col1"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
278 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
279 c = None |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
280 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
281 df_key = infile1 + repr(header) |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
282 df = pd.read_csv(infile1, sep="\t", header=header, parse_dates=True) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
283 loaded_df[df_key] = df |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
284 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
285 X = read_columns(df, c=c, c_option=column_option).astype(float) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
286 # sparse input |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
287 elif input_type == "sparse": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
288 X = mmread(open(infile1, "r")) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
289 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
290 # fasta_file input |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
291 elif input_type == "seq_fasta": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
292 pyfaidx = get_module("pyfaidx") |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
293 sequences = pyfaidx.Fasta(fasta_path) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
294 n_seqs = len(sequences.keys()) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
295 X = np.arange(n_seqs)[:, np.newaxis] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
296 for param in estimator_params.keys(): |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
297 if param.endswith("fasta_path"): |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
298 estimator.set_params(**{param: fasta_path}) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
299 break |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
300 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
301 raise ValueError( |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
302 "The selected estimator doesn't support " |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
303 "fasta file input! Please consider using " |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
304 "KerasGBatchClassifier with " |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
305 "FastaDNABatchGenerator/FastaProteinBatchGenerator " |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
306 "or having GenomeOneHotEncoder/ProteinOneHotEncoder " |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
307 "in pipeline!" |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
308 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
309 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
310 elif input_type == "refseq_and_interval": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
311 path_params = { |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
312 "data_batch_generator__ref_genome_path": ref_seq, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
313 "data_batch_generator__intervals_path": intervals, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
314 "data_batch_generator__target_path": targets, |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
315 } |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
316 estimator.set_params(**path_params) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
317 n_intervals = sum(1 for line in open(intervals)) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
318 X = np.arange(n_intervals)[:, np.newaxis] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
319 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
320 # Get target y |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
321 header = "infer" if params["input_options"]["header2"] else None |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
322 column_option = params["input_options"]["column_selector_options_2"][ |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
323 "selected_column_selector_option2" |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
324 ] |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
325 if column_option in [ |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
326 "by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
327 "all_but_by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
328 "by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
329 "all_but_by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
330 ]: |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
331 c = params["input_options"]["column_selector_options_2"]["col2"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
332 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
333 c = None |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
334 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
335 df_key = infile2 + repr(header) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
336 if df_key in loaded_df: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
337 infile2 = loaded_df[df_key] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
338 else: |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
339 infile2 = pd.read_csv(infile2, sep="\t", header=header, parse_dates=True) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
340 loaded_df[df_key] = infile2 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
341 |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
342 y = read_columns( |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
343 infile2, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
344 c=c, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
345 c_option=column_option, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
346 sep="\t", |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
347 header=header, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
348 parse_dates=True, |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
349 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
350 if len(y.shape) == 2 and y.shape[1] == 1: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
351 y = y.ravel() |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
352 if input_type == "refseq_and_interval": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
353 estimator.set_params(data_batch_generator__features=y.ravel().tolist()) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
354 y = None |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
355 # end y |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
356 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
357 # load groups |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
358 if groups: |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
359 groups_selector = ( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
360 params["experiment_schemes"]["test_split"]["split_algos"] |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
361 ).pop("groups_selector") |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
362 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
363 header = "infer" if groups_selector["header_g"] else None |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
364 column_option = groups_selector["column_selector_options_g"][ |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
365 "selected_column_selector_option_g" |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
366 ] |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
367 if column_option in [ |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
368 "by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
369 "all_but_by_index_number", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
370 "by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
371 "all_but_by_header_name", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
372 ]: |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
373 c = groups_selector["column_selector_options_g"]["col_g"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
374 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
375 c = None |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
376 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
377 df_key = groups + repr(header) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
378 if df_key in loaded_df: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
379 groups = loaded_df[df_key] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
380 |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
381 groups = read_columns( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
382 groups, |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
383 c=c, |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
384 c_option=column_option, |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
385 sep="\t", |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
386 header=header, |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
387 parse_dates=True, |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
388 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
389 groups = groups.ravel() |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
390 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
391 # del loaded_df |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
392 del loaded_df |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
393 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
394 # cache iraps_core fits could increase search speed significantly |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
395 memory = joblib.Memory(location=CACHE_DIR, verbose=0) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
396 main_est = get_main_estimator(estimator) |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
397 if main_est.__class__.__name__ == "IRAPSClassifier": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
398 main_est.set_params(memory=memory) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
399 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
400 # handle scorer, convert to scorer dict |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
401 scoring = params["experiment_schemes"]["metrics"]["scoring"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
402 scorer = get_scoring(scoring) |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
403 if not isinstance(scorer, (dict, list)): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
404 scorer = [scoring["primary_scoring"]] |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
405 scorer = _check_multimetric_scoring(estimator, scoring=scorer) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
406 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
407 # handle test (first) split |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
408 test_split_options = params["experiment_schemes"]["test_split"]["split_algos"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
409 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
410 if test_split_options["shuffle"] == "group": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
411 test_split_options["labels"] = groups |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
412 if test_split_options["shuffle"] == "stratified": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
413 if y is not None: |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
414 test_split_options["labels"] = y |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
415 else: |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
416 raise ValueError( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
417 "Stratified shuffle split is not " "applicable on empty target values!" |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
418 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
419 |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
420 X_train, X_test, y_train, y_test, groups_train, groups_test = train_test_split_none( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
421 X, y, groups, **test_split_options |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
422 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
423 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
424 exp_scheme = params["experiment_schemes"]["selected_exp_scheme"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
425 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
426 # handle validation (second) split |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
427 if exp_scheme == "train_val_test": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
428 val_split_options = params["experiment_schemes"]["val_split"]["split_algos"] |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
429 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
430 if val_split_options["shuffle"] == "group": |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
431 val_split_options["labels"] = groups_train |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
432 if val_split_options["shuffle"] == "stratified": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
433 if y_train is not None: |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
434 val_split_options["labels"] = y_train |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
435 else: |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
436 raise ValueError( |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
437 "Stratified shuffle split is not " |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
438 "applicable on empty target values!" |
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
439 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
440 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
441 ( |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
442 X_train, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
443 X_val, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
444 y_train, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
445 y_val, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
446 groups_train, |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
447 groups_val, |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
448 ) = train_test_split_none(X_train, y_train, groups_train, **val_split_options) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
449 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
450 # train and eval |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
451 if hasattr(estimator, "config") and hasattr(estimator, "model_type"): |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
452 if exp_scheme == "train_val_test": |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
453 history = estimator.fit(X_train, y_train, validation_data=(X_val, y_val)) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
454 else: |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
455 history = estimator.fit(X_train, y_train, validation_data=(X_test, y_test)) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
456 else: |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
457 history = estimator.fit(X_train, y_train) |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
458 if "callbacks" in estimator_params: |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
459 for cb in estimator_params["callbacks"]: |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
460 if cb["callback_selection"]["callback_type"] == "CSVLogger": |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
461 hist_df = pd.DataFrame(history.history) |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
462 hist_df["epoch"] = np.arange(1, estimator_params["epochs"] + 1) |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
463 epo_col = hist_df.pop('epoch') |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
464 hist_df.insert(0, 'epoch', epo_col) |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
465 hist_df.to_csv(path_or_buf=outfile_history, sep="\t", header=True, index=False) |
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
466 break |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
467 if isinstance(estimator, KerasGBatchClassifier): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
468 scores = {} |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
469 steps = estimator.prediction_steps |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
470 batch_size = estimator.batch_size |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
471 data_generator = estimator.data_generator_ |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
472 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
473 scores, predictions, y_true = _evaluate_keras_and_sklearn_scores( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
474 estimator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
475 data_generator, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
476 X_test, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
477 y=y_test, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
478 sk_scoring=scoring, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
479 steps=steps, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
480 batch_size=batch_size, |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
481 return_predictions=bool(outfile_y_true), |
11
caf7d2b71a48
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
bgruening
parents:
10
diff
changeset
|
482 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
483 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
484 else: |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
485 scores = {} |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
486 if hasattr(estimator, "model_") and hasattr(estimator.model_, "metrics_names"): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
487 batch_size = estimator.batch_size |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
488 score_results = estimator.model_.evaluate( |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
489 X_test, y=y_test, batch_size=batch_size, verbose=0 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
490 ) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
491 metrics_names = estimator.model_.metrics_names |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
492 if not isinstance(metrics_names, list): |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
493 scores[metrics_names] = score_results |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
494 else: |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
495 scores = dict(zip(metrics_names, score_results)) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
496 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
497 if hasattr(estimator, "predict_proba"): |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
498 predictions = estimator.predict_proba(X_test) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
499 else: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
500 predictions = estimator.predict(X_test) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
501 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
502 y_true = y_test |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
503 sk_scores = _score(estimator, X_test, y_test, scorer) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
504 scores.update(sk_scores) |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
505 |
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
506 # handle output |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
507 if outfile_y_true: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
508 try: |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
509 pd.DataFrame(y_true).to_csv(outfile_y_true, sep="\t", index=False) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
510 pd.DataFrame(predictions).astype(np.float32).to_csv( |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
511 outfile_y_preds, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
512 sep="\t", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
513 index=False, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
514 float_format="%g", |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
515 chunksize=10000, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
516 ) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
517 except Exception as e: |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
518 print("Error in saving predictions: %s" % e) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
519 # handle output |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
520 for name, score in scores.items(): |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
521 scores[name] = [score] |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
522 df = pd.DataFrame(scores) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
523 df = df[sorted(df.columns)] |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
524 df.to_csv(path_or_buf=outfile_result, sep="\t", header=True, index=False) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
525 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
526 memory.clear(warn=False) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
527 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
528 if outfile_object: |
15
2eb5c017958d
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
bgruening
parents:
11
diff
changeset
|
529 dump_model_to_h5(estimator, outfile_object) |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
530 |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
531 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
532 if __name__ == "__main__": |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
533 aparser = argparse.ArgumentParser() |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
534 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
535 aparser.add_argument("-e", "--estimator", dest="infile_estimator") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
536 aparser.add_argument("-X", "--infile1", dest="infile1") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
537 aparser.add_argument("-y", "--infile2", dest="infile2") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
538 aparser.add_argument("-O", "--outfile_result", dest="outfile_result") |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
539 aparser.add_argument("-hi", "--outfile_history", dest="outfile_history") |
5
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
540 aparser.add_argument("-o", "--outfile_object", dest="outfile_object") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
541 aparser.add_argument("-l", "--outfile_y_true", dest="outfile_y_true") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
542 aparser.add_argument("-p", "--outfile_y_preds", dest="outfile_y_preds") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
543 aparser.add_argument("-g", "--groups", dest="groups") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
544 aparser.add_argument("-r", "--ref_seq", dest="ref_seq") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
545 aparser.add_argument("-b", "--intervals", dest="intervals") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
546 aparser.add_argument("-t", "--targets", dest="targets") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
547 aparser.add_argument("-f", "--fasta_path", dest="fasta_path") |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
548 args = aparser.parse_args() |
2b8406e74f9e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5b2ac730ec6d3b762faa9034eddd19ad1b347476"
bgruening
parents:
diff
changeset
|
549 |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
550 main( |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
551 args.inputs, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
552 args.infile_estimator, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
553 args.infile1, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
554 args.infile2, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
555 args.outfile_result, |
18
ddc4fe317a92
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 80417bf0158a9b596e485dd66408f738f405145a
bgruening
parents:
15
diff
changeset
|
556 outfile_history=args.outfile_history, |
9
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
557 outfile_object=args.outfile_object, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
558 outfile_y_true=args.outfile_y_true, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
559 outfile_y_preds=args.outfile_y_preds, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
560 groups=args.groups, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
561 ref_seq=args.ref_seq, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
562 intervals=args.intervals, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
563 targets=args.targets, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
564 fasta_path=args.fasta_path, |
ead7adad8d0e
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit e2a5eade6d0e5ddf3a47630381a0ad90d80e8a04"
bgruening
parents:
5
diff
changeset
|
565 ) |