From 2575a40c4ef360eee953dfa108781aecaf5908e4 Mon Sep 17 00:00:00 2001 From: Ethan Glaser Date: Thu, 5 Oct 2023 08:56:33 -0500 Subject: [PATCH 1/6] Initial sklearnex support --- tpot2/config/__init__.py | 2 + tpot2/config/classifiers_sklearnex.py | 87 +++++++++++++++ tpot2/config/regressors_sklearnex.py | 100 ++++++++++++++++++ tpot2/tpot_estimator/estimator.py | 16 ++- tpot2/tpot_estimator/estimator_utils.py | 6 ++ .../tpot_estimator/templates/tpottemplates.py | 12 ++- 6 files changed, 217 insertions(+), 6 deletions(-) create mode 100644 tpot2/config/classifiers_sklearnex.py create mode 100644 tpot2/config/regressors_sklearnex.py diff --git a/tpot2/config/__init__.py b/tpot2/config/__init__.py index c5c18117..58b6273a 100644 --- a/tpot2/config/__init__.py +++ b/tpot2/config/__init__.py @@ -1,7 +1,9 @@ #TODO: make configuration dictionaries optinally based on strings? from .classifiers import make_classifier_config_dictionary +from .classifiers_sklearnex import make_sklearnex_classifier_config_dictionary from .transformers import make_transformer_config_dictionary from .regressors import make_regressor_config_dictionary +from .regressors_sklearnex import make_sklearnex_regressor_config_dictionary from .selectors import make_selector_config_dictionary from .special_configs import make_arithmetic_transformer_config_dictionary, make_FSS_config_dictionary, make_passthrough_config_dictionary from .autoqtl_builtins import make_FeatureEncodingFrequencySelector_config_dictionary, make_genetic_encoders_config_dictionary diff --git a/tpot2/config/classifiers_sklearnex.py b/tpot2/config/classifiers_sklearnex.py new file mode 100644 index 00000000..03ed9b4d --- /dev/null +++ b/tpot2/config/classifiers_sklearnex.py @@ -0,0 +1,87 @@ +from sklearnex.ensemble import RandomForestClassifier +from xgboost import XGBClassifier +from sklearnex.neighbors import KNeighborsClassifier +from sklearnex.svm import SVC +from sklearnex.svm import NuSVC +from sklearnex.linear_model import LogisticRegression + +from functools import partial + + +def params_RandomForestClassifier(trial, name=None): + return { + 'n_estimators': 100, + 'bootstrap': trial.suggest_categorical(name=f'bootstrap_{name}', choices=[True, False]), + 'min_samples_split': trial.suggest_int(f'min_samples_split_{name}', 2, 20), + 'min_samples_leaf': trial.suggest_int(f'min_samples_leaf_{name}', 1, 20), + 'n_jobs': 1, + } + +def params_KNeighborsClassifier(trial, name=None, n_samples=10): + n_neighbors_max = max(n_samples, 100) + return { + 'n_neighbors': trial.suggest_int(f'n_neighbors_{name}', 1, n_neighbors_max, log=True ), + 'weights': trial.suggest_categorical(f'weights_{name}', ['uniform', 'distance']), + } + +def params_LogisticRegression(trial, name=None): + params = {} + params['dual'] = False + params['penalty'] = 'l2' + params['solver'] = trial.suggest_categorical(name=f'solver_{name}', choices=['liblinear', 'sag', 'saga']), + if params['solver'] == 'liblinear': + params['penalty'] = trial.suggest_categorical(name=f'penalty_{name}', choices=['l1', 'l2']) + if params['penalty'] == 'l2': + params['dual'] = trial.suggest_categorical(name=f'dual_{name}', choices=[True, False]) + else: + params['penalty'] = 'l1' + return { + 'solver': params['solver'], + 'penalty': params['penalty'], + 'dual': params['dual'], + 'C': trial.suggest_float(f'C_{name}', 1e-4, 1e4, log=True), + 'max_iter': 1000, + } + +def params_SVC(trial, name=None): + return { + 'kernel': trial.suggest_categorical(name=f'kernel_{name}', choices=['poly', 'rbf', 'linear', 'sigmoid']), + 'C': trial.suggest_float(f'C_{name}', 1e-4, 25, log=True), + 'degree': trial.suggest_int(f'degree_{name}', 1, 4), + 'class_weight': trial.suggest_categorical(name=f'class_weight_{name}', choices=[None, 'balanced']), + 'max_iter': 3000, + 'tol': 0.005, + 'probability': True, + } + +def params_NuSVC(trial, name=None): + return { + 'nu': trial.suggest_float(f'subsample_{name}', 0.05, 1.0), + 'kernel': trial.suggest_categorical(name=f'kernel_{name}', choices=['poly', 'rbf', 'linear', 'sigmoid']), + 'C': trial.suggest_float(f'C_{name}', 1e-4, 25, log=True), + 'degree': trial.suggest_int(f'degree_{name}', 1, 4), + 'class_weight': trial.suggest_categorical(name=f'class_weight_{name}', choices=[None, 'balanced']), + 'max_iter': 3000, + 'tol': 0.005, + 'probability': True, + } + +def params_XGBClassifier(trial, name=None): + return { + 'learning_rate': trial.suggest_float(f'learning_rate_{name}', 1e-3, 1, log=True), + 'subsample': trial.suggest_float(f'subsample_{name}', 0.1, 1.0), + 'min_child_weight': trial.suggest_int(f'min_child_weight_{name}', 1, 21), + 'n_estimators': 100, + 'max_depth': trial.suggest_int(f'max_depth_{name}', 1, 11), + 'n_jobs': 1, + } + +def make_sklearnex_classifier_config_dictionary(n_samples=10, n_classes=None): + return { + RandomForestClassifier: params_RandomForestClassifier, + KNeighborsClassifier: params_KNeighborsClassifier, + LogisticRegression: params_LogisticRegression, + SVC: params_SVC, + NuSVC: params_NuSVC, + XGBClassifier: params_XGBClassifier, + } diff --git a/tpot2/config/regressors_sklearnex.py b/tpot2/config/regressors_sklearnex.py new file mode 100644 index 00000000..c9b370cf --- /dev/null +++ b/tpot2/config/regressors_sklearnex.py @@ -0,0 +1,100 @@ +from sklearnex.linear_model import LinearRegression +from sklearnex.linear_model import Ridge +from sklearnex.linear_model import Lasso +from sklearnex.linear_model import ElasticNet + +from sklearnex.svm import SVR +from sklearnex.svm import NuSVR + +from sklearnex.ensemble import RandomForestRegressor +from sklearnex.neighbors import KNeighborsRegressor + +from xgboost import XGBRegressor +from functools import partial + + +def params_RandomForestRegressor(trial, name=None): + return { + 'n_estimators': 100, + 'max_features': trial.suggest_float(f'max_features_{name}', 0.05, 1.0), + 'bootstrap': trial.suggest_categorical(name=f'bootstrap_{name}', choices=[True, False]), + 'min_samples_split': trial.suggest_int(f'min_samples_split_{name}', 2, 21), + 'min_samples_leaf': trial.suggest_int(f'min_samples_leaf_{name}', 1, 21), + } + +def params_KNeighborsRegressor(trial, name=None, n_samples=100): + n_neighbors_max = max(n_samples, 100) + return { + 'n_neighbors': trial.suggest_int(f'n_neighbors_{name}', 1, n_neighbors_max), + 'weights': trial.suggest_categorical(f'weights_{name}', ['uniform', 'distance']), + } + +def params_LinearRegression(trial, name=None): + return {} + +def params_Ridge(trial, name=None): + return { + 'alpha': trial.suggest_float(f'alpha_{name}', 0.0, 1.0), + 'fit_intercept': True, + 'tol': trial.suggest_float(f'tol_{name}', 1e-5, 1e-1, log=True), + } + +def params_Lasso(trial, name=None): + return { + 'alpha': trial.suggest_float(f'alpha_{name}', 0.0, 1.0), + 'fit_intercept': True, + 'precompute': trial.suggest_categorical(f'precompute_{name}', [True, False, 'auto']), + 'tol': trial.suggest_float(f'tol_{name}', 1e-5, 1e-1, log=True), + 'positive': trial.suggest_categorical(f'positive_{name}', [True, False]), + 'selection': trial.suggest_categorical(f'selection_{name}', ['cyclic', 'random']), + } + +def params_ElasticNet(trial, name=None): + return { + 'alpha': 1 - trial.suggest_float(f'alpha_{name}', 0.0, 1.0, log=True), + 'l1_ratio': 1- trial.suggest_float(f'l1_ratio_{name}',0.0, 1.0), + } + +def params_SVR(trial, name=None): + return { + 'kernel': trial.suggest_categorical(name=f'kernel_{name}', choices=['poly', 'rbf', 'linear', 'sigmoid']), + 'C': trial.suggest_float(f'C_{name}', 1e-4, 25, log=True), + 'degree': trial.suggest_int(f'degree_{name}', 1, 4), + 'max_iter': 3000, + 'tol': 0.005, + } + +def params_NuSVR(trial, name=None): + return { + 'nu': trial.suggest_float(f'subsample_{name}', 0.05, 1.0), + 'kernel': trial.suggest_categorical(name=f'kernel_{name}', choices=['poly', 'rbf', 'linear', 'sigmoid']), + 'C': trial.suggest_float(f'C_{name}', 1e-4, 25, log=True), + 'degree': trial.suggest_int(f'degree_{name}', 1, 4), + 'max_iter': 3000, + 'tol': 0.005, + } + +def params_XGBRegressor(trial, name=None): + return { + 'learning_rate': trial.suggest_float(f'learning_rate_{name}', 1e-3, 1, log=True), + 'subsample': trial.suggest_float(f'subsample_{name}', 0.05, 1.0), + 'min_child_weight': trial.suggest_int(f'min_child_weight_{name}', 1, 21), + 'n_estimators': 100, + 'max_depth': trial.suggest_int(f'max_depth_{name}', 1, 11), + 'nthread': 1, + 'verbosity': 0, + 'objective': 'reg:squarederror', + } + +def make_sklearnex_regressor_config_dictionary(n_samples=10): + return { + RandomForestRegressor: params_RandomForestRegressor, + KNeighborsRegressor: params_KNeighborsRegressor, + LinearRegression: params_LinearRegression, + Ridge: params_Ridge, + Lasso: params_Lasso, + ElasticNet: params_ElasticNet, + SVR: params_SVR, + NuSVR: params_NuSVR, + XGBRegressor: params_XGBRegressor, + } diff --git a/tpot2/tpot_estimator/estimator.py b/tpot2/tpot_estimator/estimator.py index 1bbe64f0..4bd642bd 100644 --- a/tpot2/tpot_estimator/estimator.py +++ b/tpot2/tpot_estimator/estimator.py @@ -94,6 +94,9 @@ def __init__(self, scorers, memory_limit = "4GB", client = None, processes = True, + + #accelerators + use_sklearnex=False, #debugging and logging parameters warm_start = False, @@ -367,6 +370,8 @@ def __init__(self, scorers, If True, will use multiprocessing to parallelize the optimization process. If False, will use threading. True seems to perform better. However, False is required for interactive debugging. + use_sklearnex : bool, default=False + If True, will use sklearnex config files that leverage accelerations from the Intel(R) Extension for Sciki-learn. warm_start : bool, default=False If True, will use the continue the evolutionary algorithm from the last generation of the previous run. @@ -475,6 +480,7 @@ def __init__(self, scorers, self.periodic_checkpoint_folder = periodic_checkpoint_folder self.callback = callback self.processes = processes + self.use_sklearnex = use_sklearnex self.scatter = scatter @@ -632,9 +638,15 @@ def fit(self, X, y): if self.root_config_dict == 'Auto': if self.classification: n_classes = len(np.unique(y)) - root_config_dict = get_configuration_dictionary("classifiers", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) + if self.use_sklearnex: + root_config_dict = get_configuration_dictionary("classifiers_sklearnex", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) + else: + root_config_dict = get_configuration_dictionary("classifiers", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) else: - root_config_dict = get_configuration_dictionary("regressors", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) + if self.use_sklearnex: + root_config_dict = get_configuration_dictionary("regressors_sklearnex", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) + else: + root_config_dict = get_configuration_dictionary("regressors", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) else: root_config_dict = get_configuration_dictionary(self.root_config_dict, n_samples, n_features, self.classification, subsets=self.subsets,feature_names=self.feature_names) diff --git a/tpot2/tpot_estimator/estimator_utils.py b/tpot2/tpot_estimator/estimator_utils.py index fe7a61a7..27ab8bc6 100644 --- a/tpot2/tpot_estimator/estimator_utils.py +++ b/tpot2/tpot_estimator/estimator_utils.py @@ -41,7 +41,13 @@ def get_configuration_dictionary(options, n_samples, n_features, classification, elif option == "classifiers": config_dict.update(tpot2.config.make_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) + elif option == "classifiers_sklearnex": + config_dict.update(tpot2.config.make_sklearnex_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) + elif option == "regressors": + config_dict.update(tpot2.config.make_sklearnex_regressor_config_dictionary(n_samples=n_samples)) + + elif option == "regressors_sklearnex": config_dict.update(tpot2.config.make_regressor_config_dictionary(n_samples=n_samples)) elif option == "transformers": diff --git a/tpot2/tpot_estimator/templates/tpottemplates.py b/tpot2/tpot_estimator/templates/tpottemplates.py index 6da52dad..85c85cd7 100644 --- a/tpot2/tpot_estimator/templates/tpottemplates.py +++ b/tpot2/tpot_estimator/templates/tpottemplates.py @@ -33,7 +33,8 @@ def __init__( self, periodic_checkpoint_folder = None, verbose = 0, memory_limit = "4GB", - client = None + client = None, + use_sklearnex = False ): """ See TPOTEstimator for documentation @@ -67,7 +68,8 @@ def __init__( self, verbose = verbose, classification=False, memory_limit = memory_limit, - client = client + client = client, + use_sklearnex=use_sklearnex ) @@ -99,7 +101,8 @@ def __init__( self, periodic_checkpoint_folder = None, verbose = 0, memory_limit = "4GB", - client = None + client = None, + use_sklearnex = False ): """ @@ -134,7 +137,8 @@ def __init__( self, verbose = verbose, classification=True, memory_limit = memory_limit, - client = client + client = client, + use_sklearnex=use_sklearnex ) From 75d36ec95168cfb1cad5413aed968593681b060c Mon Sep 17 00:00:00 2001 From: Ethan Glaser Date: Thu, 5 Oct 2023 14:49:46 -0500 Subject: [PATCH 2/6] removing sklearnex configs from config init --- tpot2/config/__init__.py | 2 -- tpot2/tpot_estimator/estimator_utils.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tpot2/config/__init__.py b/tpot2/config/__init__.py index 58b6273a..c5c18117 100644 --- a/tpot2/config/__init__.py +++ b/tpot2/config/__init__.py @@ -1,9 +1,7 @@ #TODO: make configuration dictionaries optinally based on strings? from .classifiers import make_classifier_config_dictionary -from .classifiers_sklearnex import make_sklearnex_classifier_config_dictionary from .transformers import make_transformer_config_dictionary from .regressors import make_regressor_config_dictionary -from .regressors_sklearnex import make_sklearnex_regressor_config_dictionary from .selectors import make_selector_config_dictionary from .special_configs import make_arithmetic_transformer_config_dictionary, make_FSS_config_dictionary, make_passthrough_config_dictionary from .autoqtl_builtins import make_FeatureEncodingFrequencySelector_config_dictionary, make_genetic_encoders_config_dictionary diff --git a/tpot2/tpot_estimator/estimator_utils.py b/tpot2/tpot_estimator/estimator_utils.py index 27ab8bc6..b7b1be41 100644 --- a/tpot2/tpot_estimator/estimator_utils.py +++ b/tpot2/tpot_estimator/estimator_utils.py @@ -42,13 +42,13 @@ def get_configuration_dictionary(options, n_samples, n_features, classification, config_dict.update(tpot2.config.make_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) elif option == "classifiers_sklearnex": - config_dict.update(tpot2.config.make_sklearnex_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) + config_dict.update(tpot2.config.classifiers_sklearnex.make_sklearnex_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) elif option == "regressors": - config_dict.update(tpot2.config.make_sklearnex_regressor_config_dictionary(n_samples=n_samples)) + config_dict.update(tpot2.config.make_regressor_config_dictionary(n_samples=n_samples)) elif option == "regressors_sklearnex": - config_dict.update(tpot2.config.make_regressor_config_dictionary(n_samples=n_samples)) + config_dict.update(tpot2.config.regressors_sklearnex.make_sklearnex_regressor_config_dictionary(n_samples=n_samples)) elif option == "transformers": config_dict.update(tpot2.config.make_transformer_config_dictionary(n_features=n_features)) From 3f5b1631d74c7664861e5ec896b19df62f1412d6 Mon Sep 17 00:00:00 2001 From: Ethan Glaser Date: Thu, 5 Oct 2023 14:50:02 -0500 Subject: [PATCH 3/6] gitignore setup additions --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a9df30b5..bff01e19 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ dask-worker-space/ *.egg-info/ .coverage target/ -.venv/ \ No newline at end of file +.venv/ +build/* +*.egg \ No newline at end of file From 5c90d96756f49cecc3a0b1fb8e0d2d7f4cf7f298 Mon Sep 17 00:00:00 2001 From: Ethan Glaser Date: Thu, 5 Oct 2023 15:10:21 -0500 Subject: [PATCH 4/6] additional fix to optionally init sklearnex functs --- tpot2/config/__init__.py | 6 ++++++ tpot2/tpot_estimator/estimator_utils.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tpot2/config/__init__.py b/tpot2/config/__init__.py index c5c18117..e019b78e 100644 --- a/tpot2/config/__init__.py +++ b/tpot2/config/__init__.py @@ -7,6 +7,12 @@ from .autoqtl_builtins import make_FeatureEncodingFrequencySelector_config_dictionary, make_genetic_encoders_config_dictionary from .hyperparametersuggestor import * +try: + from .classifiers_sklearnex import make_sklearnex_classifier_config_dictionary + from .regressors_sklearnex import make_sklearnex_regressor_config_dictionary +except ModuleNotFoundError: #if optional packages are not installed + pass + try: from .mdr_configs import make_skrebate_config_dictionary, make_MDR_config_dictionary, make_ContinuousMDR_config_dictionary except: #if optional packages are not installed diff --git a/tpot2/tpot_estimator/estimator_utils.py b/tpot2/tpot_estimator/estimator_utils.py index b7b1be41..08d25f1b 100644 --- a/tpot2/tpot_estimator/estimator_utils.py +++ b/tpot2/tpot_estimator/estimator_utils.py @@ -42,13 +42,13 @@ def get_configuration_dictionary(options, n_samples, n_features, classification, config_dict.update(tpot2.config.make_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) elif option == "classifiers_sklearnex": - config_dict.update(tpot2.config.classifiers_sklearnex.make_sklearnex_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) + config_dict.update(tpot2.config.make_sklearnex_classifier_config_dictionary(n_samples=n_samples, n_classes=n_classes)) elif option == "regressors": config_dict.update(tpot2.config.make_regressor_config_dictionary(n_samples=n_samples)) elif option == "regressors_sklearnex": - config_dict.update(tpot2.config.regressors_sklearnex.make_sklearnex_regressor_config_dictionary(n_samples=n_samples)) + config_dict.update(tpot2.config.make_sklearnex_regressor_config_dictionary(n_samples=n_samples)) elif option == "transformers": config_dict.update(tpot2.config.make_transformer_config_dictionary(n_features=n_features)) From ef35d95ec163bf27740f8f8991ea3fa57b003abe Mon Sep 17 00:00:00 2001 From: Ethan Glaser Date: Thu, 5 Oct 2023 16:08:08 -0500 Subject: [PATCH 5/6] remove use_sklearnex and xgboost --- tpot2/config/classifiers_sklearnex.py | 14 -------------- tpot2/config/regressors_sklearnex.py | 16 ---------------- tpot2/tpot_estimator/estimator.py | 16 ++-------------- tpot2/tpot_estimator/templates/tpottemplates.py | 12 ++++-------- 4 files changed, 6 insertions(+), 52 deletions(-) diff --git a/tpot2/config/classifiers_sklearnex.py b/tpot2/config/classifiers_sklearnex.py index 03ed9b4d..7d4129d0 100644 --- a/tpot2/config/classifiers_sklearnex.py +++ b/tpot2/config/classifiers_sklearnex.py @@ -1,12 +1,9 @@ from sklearnex.ensemble import RandomForestClassifier -from xgboost import XGBClassifier from sklearnex.neighbors import KNeighborsClassifier from sklearnex.svm import SVC from sklearnex.svm import NuSVC from sklearnex.linear_model import LogisticRegression -from functools import partial - def params_RandomForestClassifier(trial, name=None): return { @@ -66,16 +63,6 @@ def params_NuSVC(trial, name=None): 'probability': True, } -def params_XGBClassifier(trial, name=None): - return { - 'learning_rate': trial.suggest_float(f'learning_rate_{name}', 1e-3, 1, log=True), - 'subsample': trial.suggest_float(f'subsample_{name}', 0.1, 1.0), - 'min_child_weight': trial.suggest_int(f'min_child_weight_{name}', 1, 21), - 'n_estimators': 100, - 'max_depth': trial.suggest_int(f'max_depth_{name}', 1, 11), - 'n_jobs': 1, - } - def make_sklearnex_classifier_config_dictionary(n_samples=10, n_classes=None): return { RandomForestClassifier: params_RandomForestClassifier, @@ -83,5 +70,4 @@ def make_sklearnex_classifier_config_dictionary(n_samples=10, n_classes=None): LogisticRegression: params_LogisticRegression, SVC: params_SVC, NuSVC: params_NuSVC, - XGBClassifier: params_XGBClassifier, } diff --git a/tpot2/config/regressors_sklearnex.py b/tpot2/config/regressors_sklearnex.py index c9b370cf..f37f14bb 100644 --- a/tpot2/config/regressors_sklearnex.py +++ b/tpot2/config/regressors_sklearnex.py @@ -9,9 +9,6 @@ from sklearnex.ensemble import RandomForestRegressor from sklearnex.neighbors import KNeighborsRegressor -from xgboost import XGBRegressor -from functools import partial - def params_RandomForestRegressor(trial, name=None): return { @@ -74,18 +71,6 @@ def params_NuSVR(trial, name=None): 'tol': 0.005, } -def params_XGBRegressor(trial, name=None): - return { - 'learning_rate': trial.suggest_float(f'learning_rate_{name}', 1e-3, 1, log=True), - 'subsample': trial.suggest_float(f'subsample_{name}', 0.05, 1.0), - 'min_child_weight': trial.suggest_int(f'min_child_weight_{name}', 1, 21), - 'n_estimators': 100, - 'max_depth': trial.suggest_int(f'max_depth_{name}', 1, 11), - 'nthread': 1, - 'verbosity': 0, - 'objective': 'reg:squarederror', - } - def make_sklearnex_regressor_config_dictionary(n_samples=10): return { RandomForestRegressor: params_RandomForestRegressor, @@ -96,5 +81,4 @@ def make_sklearnex_regressor_config_dictionary(n_samples=10): ElasticNet: params_ElasticNet, SVR: params_SVR, NuSVR: params_NuSVR, - XGBRegressor: params_XGBRegressor, } diff --git a/tpot2/tpot_estimator/estimator.py b/tpot2/tpot_estimator/estimator.py index 4bd642bd..1bbe64f0 100644 --- a/tpot2/tpot_estimator/estimator.py +++ b/tpot2/tpot_estimator/estimator.py @@ -94,9 +94,6 @@ def __init__(self, scorers, memory_limit = "4GB", client = None, processes = True, - - #accelerators - use_sklearnex=False, #debugging and logging parameters warm_start = False, @@ -370,8 +367,6 @@ def __init__(self, scorers, If True, will use multiprocessing to parallelize the optimization process. If False, will use threading. True seems to perform better. However, False is required for interactive debugging. - use_sklearnex : bool, default=False - If True, will use sklearnex config files that leverage accelerations from the Intel(R) Extension for Sciki-learn. warm_start : bool, default=False If True, will use the continue the evolutionary algorithm from the last generation of the previous run. @@ -480,7 +475,6 @@ def __init__(self, scorers, self.periodic_checkpoint_folder = periodic_checkpoint_folder self.callback = callback self.processes = processes - self.use_sklearnex = use_sklearnex self.scatter = scatter @@ -638,15 +632,9 @@ def fit(self, X, y): if self.root_config_dict == 'Auto': if self.classification: n_classes = len(np.unique(y)) - if self.use_sklearnex: - root_config_dict = get_configuration_dictionary("classifiers_sklearnex", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) - else: - root_config_dict = get_configuration_dictionary("classifiers", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) + root_config_dict = get_configuration_dictionary("classifiers", n_samples, n_features, self.classification, subsets=self.subsets, feature_names=self.feature_names, n_classes=n_classes) else: - if self.use_sklearnex: - root_config_dict = get_configuration_dictionary("regressors_sklearnex", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) - else: - root_config_dict = get_configuration_dictionary("regressors", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) + root_config_dict = get_configuration_dictionary("regressors", n_samples, n_features, self.classification,subsets=self.subsets, feature_names=self.feature_names) else: root_config_dict = get_configuration_dictionary(self.root_config_dict, n_samples, n_features, self.classification, subsets=self.subsets,feature_names=self.feature_names) diff --git a/tpot2/tpot_estimator/templates/tpottemplates.py b/tpot2/tpot_estimator/templates/tpottemplates.py index 85c85cd7..6da52dad 100644 --- a/tpot2/tpot_estimator/templates/tpottemplates.py +++ b/tpot2/tpot_estimator/templates/tpottemplates.py @@ -33,8 +33,7 @@ def __init__( self, periodic_checkpoint_folder = None, verbose = 0, memory_limit = "4GB", - client = None, - use_sklearnex = False + client = None ): """ See TPOTEstimator for documentation @@ -68,8 +67,7 @@ def __init__( self, verbose = verbose, classification=False, memory_limit = memory_limit, - client = client, - use_sklearnex=use_sklearnex + client = client ) @@ -101,8 +99,7 @@ def __init__( self, periodic_checkpoint_folder = None, verbose = 0, memory_limit = "4GB", - client = None, - use_sklearnex = False + client = None ): """ @@ -137,8 +134,7 @@ def __init__( self, verbose = verbose, classification=True, memory_limit = memory_limit, - client = client, - use_sklearnex=use_sklearnex + client = client ) From 1f6d511c3095d6b46079188f036b90fc5db7eacd Mon Sep 17 00:00:00 2001 From: Pedro Ribeiro Date: Fri, 6 Oct 2023 13:34:44 -0700 Subject: [PATCH 6/6] Update regressors_sklearnex.py --- tpot2/config/regressors_sklearnex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpot2/config/regressors_sklearnex.py b/tpot2/config/regressors_sklearnex.py index f37f14bb..4eb10f1c 100644 --- a/tpot2/config/regressors_sklearnex.py +++ b/tpot2/config/regressors_sklearnex.py @@ -48,7 +48,7 @@ def params_Lasso(trial, name=None): def params_ElasticNet(trial, name=None): return { - 'alpha': 1 - trial.suggest_float(f'alpha_{name}', 0.0, 1.0, log=True), + 'alpha': 1 - trial.suggest_float(f'alpha_{name}', 0.0, 1.0), 'l1_ratio': 1- trial.suggest_float(f'l1_ratio_{name}',0.0, 1.0), }