diff --git a/README.md b/README.md index f7551551..04920a14 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,34 @@ conda create --name tpot2env python=3.10 conda activate tpot2env ``` +### Packages Used + +python version <3.12 +numpy +scipy +scikit-learn +update_checker +tqdm +stopit +pandas +joblib +xgboost +matplotlib +traitlets +lightgbm +optuna +baikal +jupyter +networkx> +dask +distributed +dask-ml +dask-jobqueue +func_timeout +configspace + +Many of the hyperparameter ranges used in our configspaces were adapted from either the original TPOT package or the AutoSklearn package. + ### Note for M1 Mac or other Arm-based CPU users You need to install the lightgbm package directly from conda using the following command before installing TPOT2. diff --git a/tpot2/config/classifiers.py b/tpot2/config/classifiers.py index 6423f328..4be33797 100644 --- a/tpot2/config/classifiers.py +++ b/tpot2/config/classifiers.py @@ -292,8 +292,8 @@ def get_PassiveAggressiveClassifier_ConfigurationSpace(random_state): #TODO support auto shrinkage when solver is svd. may require custom node def get_LinearDiscriminantAnalysis_ConfigurationSpace(): - solver = Categorical("solver", ['svd', 'lsqr', 'eigen']), - shrinkage = Float("shrinkage", bounds=(0, 1)), + solver = Categorical("solver", ['svd', 'lsqr', 'eigen']) + shrinkage = Float("shrinkage", bounds=(0, 1)) shrinkcond = NotEqualsCondition(shrinkage, solver, 'svd') @@ -301,7 +301,7 @@ def get_LinearDiscriminantAnalysis_ConfigurationSpace(): cs.add_hyperparameters([solver, shrinkage]) cs.add_conditions([shrinkcond]) - return + return cs diff --git a/tpot2/config/get_configspace.py b/tpot2/config/get_configspace.py index 473233ea..19dfb531 100644 --- a/tpot2/config/get_configspace.py +++ b/tpot2/config/get_configspace.py @@ -192,6 +192,8 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta #classifiers.py + case "LinearDiscriminantAnalysis": + return classifiers.get_LinearDiscriminantAnalysis_ConfigurationSpace() case "AdaBoostClassifier": return classifiers.get_AdaBoostClassifier_ConfigurationSpace(random_state=random_state) case "LogisticRegression": @@ -232,6 +234,10 @@ def get_configspace(name, n_classes=3, n_samples=100, n_features=100, random_sta return regressors.ElasticNetCV_configspace case "RidgeCV": return {} + case "PassiveAggressiveClassifier": + return classifiers.get_PassiveAggressiveClassifier_ConfigurationSpace(random_state=random_state) + case "QuadraticDiscriminantAnalysis": + return classifiers.get_QuadraticDiscriminantAnalysis_ConfigurationSpace() #regressors.py case "RandomForestRegressor": diff --git a/tpot2/tests/test_estimators.py b/tpot2/tests/test_estimators.py index 98b607e0..f1f3d45a 100644 --- a/tpot2/tests/test_estimators.py +++ b/tpot2/tests/test_estimators.py @@ -4,11 +4,29 @@ import random import sklearn +@pytest.fixture +def sample_dataset(): + X_train, y_train = load_iris(return_X_y=True) + return X_train, y_train + #standard test @pytest.fixture def tpot_estimator(): - return tpot2.TPOTEstimator( population_size=10, - generations=5, + + n_classes=3 + n_samples=100 + n_features=100 + + search_space = tpot2.search_spaces.pipelines.GraphPipeline( + root_search_space= tpot2.config.get_search_space("classifiers", n_samples=n_samples, n_features=n_features, n_classes=n_classes), + leaf_search_space = None, + inner_search_space = tpot2.config.get_search_space(["selectors","transformers","classifiers"],n_samples=n_samples, n_features=n_features, n_classes=n_classes), + max_size = 10, + ) + return tpot2.TPOTEstimator( + search_space=search_space, + population_size=10, + generations=2, scorers=['roc_auc_ovr'], scorers_weights=[1], classification=True, @@ -16,13 +34,18 @@ def tpot_estimator(): early_stop=5, other_objective_functions= [], other_objective_functions_weights=[], - max_time_seconds=300, + max_time_seconds=30, verbose=3) @pytest.fixture -def sample_dataset(): - X_train, y_train = load_iris(return_X_y=True) - return X_train, y_train +def tpot_classifier(): + return tpot2.tpot_estimator.templates.TPOTClassifier(max_time_seconds=10,verbose=3) + +@pytest.fixture +def tpot_regressor(): + return tpot2.tpot_estimator.templates.TPOTRegressor(max_time_seconds=10,verbose=3) + + def test_tpot_estimator_fit(tpot_estimator,sample_dataset): #load iris dataset @@ -80,13 +103,7 @@ def test_tpot_estimator_config_dict_type(): -@pytest.fixture -def tpot_classifier(): - return tpot2.tpot_estimator.templates.TPOTClassifier(max_time_seconds=10,verbose=3) -@pytest.fixture -def tpot_regressor(): - return tpot2.tpot_estimator.templates.TPOTRegressor(max_time_seconds=10,verbose=3) def test_tpot_classifier_fit(tpot_classifier,sample_dataset): #load iris dataset