Mercurial > repos > bgruening > keras_batch_models
comparison stacking_ensembles.py @ 10:33af12059f42 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit ca87db9c038a6fcf96aa39da50f384865fd932ff"
| author | bgruening |
|---|---|
| date | Tue, 20 Apr 2021 16:36:29 +0000 |
| parents | 5369fdfec6a6 |
| children | 70846a2dd227 |
comparison
equal
deleted
inserted
replaced
| 9:5369fdfec6a6 | 10:33af12059f42 |
|---|---|
| 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 |
