Mercurial > repos > bgruening > keras_model_config
comparison stacking_ensembles.py @ 11:0c933465d70e draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ea12f973df4b97a2691d9e4ce6bf6fae59d57717"
author | bgruening |
---|---|
date | Sat, 01 May 2021 00:59:48 +0000 |
parents | 64bbfa592868 |
children | 6eb4e7fb0f91 |
comparison
equal
deleted
inserted
replaced
10:64bbfa592868 | 11:0c933465d70e |
---|---|
6 import warnings | 6 import warnings |
7 | 7 |
8 import mlxtend.classifier | 8 import mlxtend.classifier |
9 import mlxtend.regressor | 9 import mlxtend.regressor |
10 import pandas as pd | 10 import pandas as pd |
11 from galaxy_ml.utils import get_cv, get_estimator, get_search_params, load_model | 11 from galaxy_ml.utils import (get_cv, get_estimator, get_search_params, |
12 | 12 load_model) |
13 | 13 |
14 warnings.filterwarnings("ignore") | 14 warnings.filterwarnings("ignore") |
15 | 15 |
16 N_JOBS = int(__import__("os").environ.get("GALAXY_SLOTS", 1)) | 16 N_JOBS = int(__import__("os").environ.get("GALAXY_SLOTS", 1)) |
17 | 17 |
60 if estimator_type.startswith("mlxtend"): | 60 if estimator_type.startswith("mlxtend"): |
61 if meta_path: | 61 if meta_path: |
62 with open(meta_path, "rb") as f: | 62 with open(meta_path, "rb") as f: |
63 meta_estimator = load_model(f) | 63 meta_estimator = load_model(f) |
64 else: | 64 else: |
65 estimator_json = params["algo_selection"]["meta_estimator"]["estimator_selector"] | 65 estimator_json = params["algo_selection"]["meta_estimator"][ |
66 "estimator_selector" | |
67 ] | |
66 meta_estimator = get_estimator(estimator_json) | 68 meta_estimator = get_estimator(estimator_json) |
67 | 69 |
68 options = params["algo_selection"]["options"] | 70 options = params["algo_selection"]["options"] |
69 | 71 |
70 cv_selector = options.pop("cv_selector", None) | 72 cv_selector = options.pop("cv_selector", None) |
87 if estimator_type.startswith("sklearn"): | 89 if estimator_type.startswith("sklearn"): |
88 options["n_jobs"] = N_JOBS | 90 options["n_jobs"] = N_JOBS |
89 ensemble_estimator = klass(base_estimators, **options) | 91 ensemble_estimator = klass(base_estimators, **options) |
90 | 92 |
91 elif mod == mlxtend.classifier: | 93 elif mod == mlxtend.classifier: |
92 ensemble_estimator = klass(classifiers=base_estimators, meta_classifier=meta_estimator, **options) | 94 ensemble_estimator = klass( |
95 classifiers=base_estimators, meta_classifier=meta_estimator, **options | |
96 ) | |
93 | 97 |
94 else: | 98 else: |
95 ensemble_estimator = klass(regressors=base_estimators, meta_regressor=meta_estimator, **options) | 99 ensemble_estimator = klass( |
100 regressors=base_estimators, meta_regressor=meta_estimator, **options | |
101 ) | |
96 | 102 |
97 print(ensemble_estimator) | 103 print(ensemble_estimator) |
98 for base_est in base_estimators: | 104 for base_est in base_estimators: |
99 print(base_est) | 105 print(base_est) |
100 | 106 |