mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-15 18:35:03 -05:00
support latest xgboost version (#599)
* support latest xgboost version * Update test_classification.py * Update Exists problems when installing xgb1.6.1 in py3.6 * cleanup * xgboost version * remove time_budget_s in test * remove redundancy * stop support of python 3.6 Co-authored-by: zsk <shaokunzhang529@gmail.com> Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu>
This commit is contained in:
@@ -85,6 +85,22 @@ class TestClassification(unittest.TestCase):
|
||||
)
|
||||
y = pd.Series([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1])
|
||||
|
||||
automl = AutoML()
|
||||
automl_settings = {
|
||||
"time_budget": 3,
|
||||
"task": "classification",
|
||||
"n_jobs": 1,
|
||||
"estimator_list": ["xgboost", "catboost", "kneighbor"],
|
||||
"eval_method": "cv",
|
||||
"n_splits": 3,
|
||||
"metric": "accuracy",
|
||||
"log_training_metric": True,
|
||||
# "verbose": 4,
|
||||
"ensemble": True,
|
||||
}
|
||||
automl.fit(X, y, **automl_settings)
|
||||
del automl
|
||||
|
||||
automl = AutoML()
|
||||
automl_settings = {
|
||||
"time_budget": 6,
|
||||
@@ -99,6 +115,7 @@ class TestClassification(unittest.TestCase):
|
||||
"ensemble": True,
|
||||
}
|
||||
automl.fit(X, y, **automl_settings)
|
||||
del automl
|
||||
|
||||
automl = AutoML()
|
||||
try:
|
||||
@@ -121,21 +138,7 @@ class TestClassification(unittest.TestCase):
|
||||
"n_concurrent_trials": n_concurrent_trials,
|
||||
}
|
||||
automl.fit(X, y, **automl_settings)
|
||||
|
||||
automl = AutoML()
|
||||
automl_settings = {
|
||||
"time_budget": 3,
|
||||
"task": "classification",
|
||||
"n_jobs": 1,
|
||||
"estimator_list": ["xgboost", "catboost", "kneighbor"],
|
||||
"eval_method": "cv",
|
||||
"n_splits": 3,
|
||||
"metric": "accuracy",
|
||||
"log_training_metric": True,
|
||||
# "verbose": 4,
|
||||
"ensemble": True,
|
||||
}
|
||||
automl.fit(X, y, **automl_settings)
|
||||
del automl
|
||||
|
||||
automl = AutoML()
|
||||
automl_settings = {
|
||||
@@ -151,6 +154,7 @@ class TestClassification(unittest.TestCase):
|
||||
"ensemble": True,
|
||||
}
|
||||
automl.fit(X, y, **automl_settings)
|
||||
del automl
|
||||
|
||||
def test_binary(self):
|
||||
automl_experiment = AutoML()
|
||||
@@ -208,7 +212,7 @@ class TestClassification(unittest.TestCase):
|
||||
_ = automl_experiment.predict(fake_df)
|
||||
|
||||
def test_sparse_matrix_xgboost(self):
|
||||
automl_experiment = AutoML()
|
||||
automl = AutoML()
|
||||
automl_settings = {
|
||||
"time_budget": 3,
|
||||
"metric": "ap",
|
||||
@@ -223,15 +227,28 @@ class TestClassification(unittest.TestCase):
|
||||
import xgboost as xgb
|
||||
|
||||
callback = xgb.callback.TrainingCallback()
|
||||
automl_experiment.fit(
|
||||
automl.fit(
|
||||
X_train=X_train, y_train=y_train, callbacks=[callback], **automl_settings
|
||||
)
|
||||
print(automl_experiment.predict(X_train))
|
||||
print(automl_experiment.model)
|
||||
print(automl_experiment.config_history)
|
||||
print(automl_experiment.best_model_for_estimator("xgboost"))
|
||||
print(automl_experiment.best_iteration)
|
||||
print(automl_experiment.best_estimator)
|
||||
print(automl.predict(X_train))
|
||||
print(automl.model)
|
||||
print(automl.config_history)
|
||||
print(automl.best_model_for_estimator("xgboost"))
|
||||
print(automl.best_iteration)
|
||||
print(automl.best_estimator)
|
||||
|
||||
# test an old version of xgboost
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "pip", "install", "xgboost==1.3.3", "--user"]
|
||||
)
|
||||
automl = AutoML()
|
||||
automl.fit(X_train=X_train, y_train=y_train, **automl_settings)
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "pip", "install", "-U", "xgboost", "--user"]
|
||||
)
|
||||
|
||||
def test_ray_classification(self):
|
||||
X, y = load_breast_cancer(return_X_y=True)
|
||||
@@ -353,5 +370,5 @@ class TestClassification(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
test = TestClassification()
|
||||
test.test_preprocess()
|
||||
|
||||
@@ -24,9 +24,7 @@ def _easy_objective(use_raytune, config):
|
||||
return
|
||||
|
||||
|
||||
def test_tune(
|
||||
smoke_test=True, externally_setup_searcher=False, use_ray=False, use_raytune=False
|
||||
):
|
||||
def test_tune(externally_setup_searcher=False, use_ray=False, use_raytune=False):
|
||||
from flaml import tune
|
||||
from flaml.searcher.blendsearch import BlendSearch
|
||||
|
||||
@@ -95,7 +93,7 @@ def test_tune(
|
||||
metric="mean_loss",
|
||||
mode="min",
|
||||
num_samples=10,
|
||||
time_budget_s=5,
|
||||
# time_budget_s=5,
|
||||
use_ray=use_ray,
|
||||
config=search_space,
|
||||
)
|
||||
@@ -107,14 +105,14 @@ def test_tune(
|
||||
|
||||
|
||||
def test_reproducibility():
|
||||
best_config_1 = test_tune(smoke_test=True)
|
||||
best_config_2 = test_tune(smoke_test=True)
|
||||
best_config_1 = test_tune()
|
||||
best_config_2 = test_tune()
|
||||
print(best_config_1)
|
||||
print(best_config_2)
|
||||
assert best_config_1 == best_config_2, "flaml.tune not reproducible"
|
||||
|
||||
best_config_1 = test_tune(smoke_test=True, externally_setup_searcher=True)
|
||||
best_config_2 = test_tune(smoke_test=True, externally_setup_searcher=True)
|
||||
best_config_1 = test_tune(externally_setup_searcher=True)
|
||||
best_config_2 = test_tune(externally_setup_searcher=True)
|
||||
print(best_config_1)
|
||||
print(best_config_2)
|
||||
assert (
|
||||
|
||||
Reference in New Issue
Block a user