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

Update warnings #1338

Merged
merged 7 commits into from
Dec 14, 2021
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
Empty file added test/__init__.py
Empty file.
24 changes: 13 additions & 11 deletions test/test_automl/test_automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def test_fit(dask_client):
metric=accuracy,
dask_client=dask_client,
)
automl.fit(
X_train, Y_train, task=MULTICLASS_CLASSIFICATION
)

automl.fit(X_train, Y_train, task=MULTICLASS_CLASSIFICATION)

score = automl.score(X_test, Y_test)
assert score > 0.8
assert count_succeses(automl.cv_results_) > 0
Expand Down Expand Up @@ -109,9 +109,9 @@ def get_roar_object_callback(
metric=accuracy,
dask_client=dask_client_single_worker,
)
automl.fit(
X_train, Y_train, task=MULTICLASS_CLASSIFICATION,
)

automl.fit(X_train, Y_train, task=MULTICLASS_CLASSIFICATION)

score = automl.score(X_test, Y_test)
assert score > 0.8
assert count_succeses(automl.cv_results_) > 0
Expand Down Expand Up @@ -224,8 +224,7 @@ def test_delete_non_candidate_models(dask_client):
max_models_on_disc=3,
)

automl.fit(X, Y, task=MULTICLASS_CLASSIFICATION,
X_test=X, y_test=Y)
automl.fit(X, Y, task=MULTICLASS_CLASSIFICATION, X_test=X, y_test=Y)

# Assert at least one model file has been deleted and that there were no
# deletion errors
Expand Down Expand Up @@ -271,7 +270,9 @@ def test_binary_score_and_include(dask_client):
metric=accuracy,
dask_client=dask_client,
)

automl.fit(X_train, Y_train, task=BINARY_CLASSIFICATION)

assert automl._task == BINARY_CLASSIFICATION

# TODO, the assumption from above is not really tested here
Expand All @@ -294,6 +295,7 @@ def test_automl_outputs(dask_client):
dask_client=dask_client,
delete_tmp_folder_after_terminate=False,
)

auto.fit(
X=X_train,
y=Y_train,
Expand All @@ -302,6 +304,7 @@ def test_automl_outputs(dask_client):
dataset_name=name,
task=MULTICLASS_CLASSIFICATION,
)

data_manager_file = os.path.join(
auto._backend.temporary_directory,
'.auto-sklearn',
Expand Down Expand Up @@ -624,9 +627,8 @@ def test_load_best_individual_model(metric, dask_client):
# We cannot easily mock a function sent to dask
# so for this test we create the whole set of models/ensembles
# but prevent it to be loaded
automl.fit(
X_train, Y_train, task=MULTICLASS_CLASSIFICATION,
)
automl.fit(X_train, Y_train, task=MULTICLASS_CLASSIFICATION)

automl._backend.load_ensemble = unittest.mock.MagicMock(return_value=None)

# A memory error occurs in the ensemble construction
Expand Down
27 changes: 23 additions & 4 deletions test/test_automl/test_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __call__(self, *args, **kwargs):
get_smac_object_callback=get_smac_object_wrapper_instance,
max_models_on_disc=None,
)

automl.fit(X_train, Y_train)

# Test that the argument is correctly passed to SMAC
Expand Down Expand Up @@ -272,6 +273,7 @@ def test_performance_over_time_no_ensemble(tmp_dir):
seed=1,
initial_configurations_via_metalearning=0,
ensemble_size=0,)

cls.fit(X_train, Y_train, X_test, Y_test)

performance_over_time = cls.performance_over_time_
Expand All @@ -297,6 +299,7 @@ def test_cv_results(tmp_dir):
original_params = copy.deepcopy(params)

cls.fit(X_train, Y_train)

cv_results = cls.cv_results_
assert isinstance(cv_results, dict), type(cv_results)
assert isinstance(cv_results['mean_test_score'], np.ndarray), type(
Expand Down Expand Up @@ -382,6 +385,7 @@ def test_leaderboard(
tmp_folder=tmp_dir,
seed=1
)

model.fit(X_train, Y_train)

for params in params_generator:
Expand Down Expand Up @@ -540,6 +544,7 @@ def test_can_pickle_classifier(tmp_dir, dask_client):
tmp_folder=tmp_dir,
dask_client=dask_client,
)

automl.fit(X_train, Y_train)

initial_predictions = automl.predict(X_test)
Expand Down Expand Up @@ -765,12 +770,14 @@ def test_autosklearn_classification_methods_returns_self(dask_client):
exclude={'feature_preprocessor': ['fast_ica']})

automl_fitted = automl.fit(X_train, y_train)

assert automl is automl_fitted

automl_ensemble_fitted = automl.fit_ensemble(y_train, ensemble_size=5)
assert automl is automl_ensemble_fitted

automl_refitted = automl.refit(X_train.copy(), y_train.copy())

assert automl is automl_refitted


Expand Down Expand Up @@ -801,12 +808,14 @@ def test_autosklearn2_classification_methods_returns_self(dask_client):
dask_client=dask_client)

automl_fitted = automl.fit(X_train, y_train)

assert automl is automl_fitted

automl_ensemble_fitted = automl.fit_ensemble(y_train, ensemble_size=5)
assert automl is automl_ensemble_fitted

automl_refitted = automl.refit(X_train.copy(), y_train.copy())

assert automl is automl_refitted

predictions = automl_fitted.predict(X_test)
Expand All @@ -824,12 +833,14 @@ def test_autosklearn2_classification_methods_returns_self_sparse(dask_client):
dask_client=dask_client)

automl_fitted = automl.fit(X_train, y_train)

assert automl is automl_fitted

automl_ensemble_fitted = automl.fit_ensemble(y_train, ensemble_size=5)
assert automl is automl_ensemble_fitted

automl_refitted = automl.refit(X_train.copy(), y_train.copy())

assert automl is automl_refitted

predictions = automl_fitted.predict(X_test)
Expand Down Expand Up @@ -933,10 +944,15 @@ def test_fit_pipeline(dask_client, task_type, resampling_strategy, disable_file_
X_test=X_test, y_test=y_test,
).get_default_configuration()

pipeline, run_info, run_value = automl.fit_pipeline(X=X_train, y=y_train, config=config,
X_test=X_test, y_test=y_test,
disable_file_output=disable_file_output,
resampling_strategy=resampling_strategy)
pipeline, run_info, run_value = automl.fit_pipeline(
X=X_train,
y=y_train,
config=config,
X_test=X_test,
y_test=y_test,
disable_file_output=disable_file_output,
resampling_strategy=resampling_strategy
)

assert isinstance(run_info.config, Configuration)
assert run_info.cutoff == 30
Expand Down Expand Up @@ -1090,11 +1106,14 @@ def test_autosklearn_anneal(as_frame):
if as_frame:
# Let autosklearn calculate the feat types
automl_fitted = automl.fit(X, y)

else:
X_, y_ = sklearn.datasets.fetch_openml(data_id=2, return_X_y=True, as_frame=True)
feat_type = ['categorical' if X_[col].dtype.name == 'category' else 'numerical'
for col in X_.columns]

automl_fitted = automl.fit(X, y, feat_type=feat_type)

assert automl is automl_fitted

automl_ensemble_fitted = automl.fit_ensemble(y, ensemble_size=5)
Expand Down
5 changes: 4 additions & 1 deletion test/test_pipeline/components/classification/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import sklearn.metrics
import numpy as np

from ...ignored_warnings import ignore_warnings, classifier_warnings


class BaseClassificationComponentTest(unittest.TestCase):
# Magic command to not run tests on base class
Expand Down Expand Up @@ -274,7 +276,8 @@ def is_unset_param_raw_predictions_val_error(err):
+ " assignment" in err.args[0])

try:
model.fit(X.copy(), y.copy())
with ignore_warnings(classifier_warnings):
model.fit(X.copy(), y.copy())
except ValueError as e:
if is_AdaBoostClassifier_error(e) or is_QDA_error(e):
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
get_dataset
import sklearn.metrics

from ...ignored_warnings import ignore_warnings, feature_preprocessing_warnings


class LiblinearComponentTest(PreprocessingTestCase):

def test_default_configuration(self):
transformation, original = _test_preprocessing(LibLinear_Preprocessor)
with ignore_warnings(feature_preprocessing_warnings):
transformation, original = _test_preprocessing(LibLinear_Preprocessor)

self.assertEqual(transformation.shape[0], original.shape[0])
self.assertFalse((transformation == 0).all())

Expand All @@ -23,7 +28,10 @@ def test_default_configuration_classify(self):
for hp_name in
default if default[
hp_name] is not None})
preprocessor.fit(X_train, Y_train)

with ignore_warnings(feature_preprocessing_warnings):
preprocessor.fit(X_train, Y_train)

X_train_trans = preprocessor.transform(X_train)
X_test_trans = preprocessor.transform(X_test)

Expand All @@ -35,6 +43,6 @@ def test_default_configuration_classify(self):
self.assertAlmostEqual(accuracy, 0.8548876745598057, places=2)

def test_preprocessing_dtype(self):
super(LiblinearComponentTest,
self)._test_preprocessing_dtype(LibLinear_Preprocessor,
test_sparse=False)

with ignore_warnings(feature_preprocessing_warnings):
super()._test_preprocessing_dtype(LibLinear_Preprocessor, test_sparse=False)
Loading