Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes, passing tests #124

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions tpot2/config/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,16 @@ 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')

cs = ConfigurationSpace()
cs.add_hyperparameters([solver, shrinkage])
cs.add_conditions([shrinkcond])

return
return cs



Expand Down
6 changes: 6 additions & 0 deletions tpot2/config/get_configspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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":
Expand Down
41 changes: 29 additions & 12 deletions tpot2/tests/test_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,48 @@
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,
n_jobs=1,
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
Expand Down Expand Up @@ -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
Expand Down
Loading