|
2 | 2 | import os
|
3 | 3 | import pathlib
|
4 | 4 | import pickle
|
5 |
| -import sys |
6 | 5 | import unittest
|
7 | 6 | from test.test_api.utils import dummy_do_dummy_prediction, dummy_eval_function, dummy_traditional_classification
|
8 | 7 |
|
@@ -63,17 +62,11 @@ def test_tabular_classification(openml_id, resampling_strategy, backend, resampl
|
63 | 62 | X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
|
64 | 63 | X, y, random_state=42)
|
65 | 64 |
|
66 |
| - include = None |
67 |
| - # for python less than 3.7, learned entity embedding |
68 |
| - # is not able to be stored on disk (only on CI) |
69 |
| - if sys.version_info < (3, 7): |
70 |
| - include = {'network_embedding': ['NoEmbedding']} |
71 | 65 | # Search for a good configuration
|
72 | 66 | estimator = TabularClassificationTask(
|
73 | 67 | backend=backend,
|
74 | 68 | resampling_strategy=resampling_strategy,
|
75 | 69 | resampling_strategy_args=resampling_strategy_args,
|
76 |
| - include_components=include, |
77 | 70 | seed=42,
|
78 | 71 | )
|
79 | 72 |
|
@@ -210,18 +203,14 @@ def test_tabular_classification(openml_id, resampling_strategy, backend, resampl
|
210 | 203 | assert 'train_loss' in incumbent_results
|
211 | 204 |
|
212 | 205 | # Check that we can pickle
|
213 |
| - # Test pickle |
214 |
| - # This can happen on python greater than 3.6 |
215 |
| - # as older python do not control the state of the logger |
216 |
| - if sys.version_info >= (3, 7): |
217 |
| - dump_file = os.path.join(estimator._backend.temporary_directory, 'dump.pkl') |
| 206 | + dump_file = os.path.join(estimator._backend.temporary_directory, 'dump.pkl') |
218 | 207 |
|
219 |
| - with open(dump_file, 'wb') as f: |
220 |
| - pickle.dump(estimator, f) |
| 208 | + with open(dump_file, 'wb') as f: |
| 209 | + pickle.dump(estimator, f) |
221 | 210 |
|
222 |
| - with open(dump_file, 'rb') as f: |
223 |
| - restored_estimator = pickle.load(f) |
224 |
| - restored_estimator.predict(X_test) |
| 211 | + with open(dump_file, 'rb') as f: |
| 212 | + restored_estimator = pickle.load(f) |
| 213 | + restored_estimator.predict(X_test) |
225 | 214 |
|
226 | 215 | # Test refit on dummy data
|
227 | 216 | estimator.refit(dataset=backend.load_datamanager())
|
@@ -264,17 +253,11 @@ def test_tabular_regression(openml_name, resampling_strategy, backend, resamplin
|
264 | 253 | X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
|
265 | 254 | X, y, random_state=1)
|
266 | 255 |
|
267 |
| - include = None |
268 |
| - # for python less than 3.7, learned entity embedding |
269 |
| - # is not able to be stored on disk (only on CI) |
270 |
| - if sys.version_info < (3, 7): |
271 |
| - include = {'network_embedding': ['NoEmbedding']} |
272 | 256 | # Search for a good configuration
|
273 | 257 | estimator = TabularRegressionTask(
|
274 | 258 | backend=backend,
|
275 | 259 | resampling_strategy=resampling_strategy,
|
276 | 260 | resampling_strategy_args=resampling_strategy_args,
|
277 |
| - include_components=include, |
278 | 261 | seed=42,
|
279 | 262 | )
|
280 | 263 |
|
@@ -403,30 +386,26 @@ def test_tabular_regression(openml_name, resampling_strategy, backend, resamplin
|
403 | 386 | assert 'train_loss' in incumbent_results, estimator.run_history.data
|
404 | 387 |
|
405 | 388 | # Check that we can pickle
|
406 |
| - # Test pickle |
407 |
| - # This can happen on python greater than 3.6 |
408 |
| - # as older python do not control the state of the logger |
409 |
| - if sys.version_info >= (3, 7): |
410 |
| - dump_file = os.path.join(estimator._backend.temporary_directory, 'dump.pkl') |
| 389 | + dump_file = os.path.join(estimator._backend.temporary_directory, 'dump.pkl') |
411 | 390 |
|
412 |
| - with open(dump_file, 'wb') as f: |
413 |
| - pickle.dump(estimator, f) |
| 391 | + with open(dump_file, 'wb') as f: |
| 392 | + pickle.dump(estimator, f) |
414 | 393 |
|
415 |
| - with open(dump_file, 'rb') as f: |
416 |
| - restored_estimator = pickle.load(f) |
417 |
| - restored_estimator.predict(X_test) |
| 394 | + with open(dump_file, 'rb') as f: |
| 395 | + restored_estimator = pickle.load(f) |
| 396 | + restored_estimator.predict(X_test) |
418 | 397 |
|
419 |
| - # Test refit on dummy data |
420 |
| - estimator.refit(dataset=backend.load_datamanager()) |
| 398 | + # Test refit on dummy data |
| 399 | + estimator.refit(dataset=backend.load_datamanager()) |
421 | 400 |
|
422 |
| - # Make sure that a configuration space is stored in the estimator |
423 |
| - assert isinstance(estimator.get_search_space(), CS.ConfigurationSpace) |
| 401 | + # Make sure that a configuration space is stored in the estimator |
| 402 | + assert isinstance(estimator.get_search_space(), CS.ConfigurationSpace) |
424 | 403 |
|
425 |
| - representation = estimator.show_models() |
426 |
| - assert isinstance(representation, str) |
427 |
| - assert 'Weight' in representation |
428 |
| - assert 'Preprocessing' in representation |
429 |
| - assert 'Estimator' in representation |
| 404 | + representation = estimator.show_models() |
| 405 | + assert isinstance(representation, str) |
| 406 | + assert 'Weight' in representation |
| 407 | + assert 'Preprocessing' in representation |
| 408 | + assert 'Estimator' in representation |
430 | 409 |
|
431 | 410 |
|
432 | 411 | @pytest.mark.parametrize('openml_id', (
|
@@ -536,16 +515,10 @@ def test_portfolio_selection(openml_id, backend, n_samples):
|
536 | 515 | X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
|
537 | 516 | X, y, random_state=1)
|
538 | 517 |
|
539 |
| - include = None |
540 |
| - # for python less than 3.7, learned entity embedding |
541 |
| - # is not able to be stored on disk (only on CI) |
542 |
| - if sys.version_info < (3, 7): |
543 |
| - include = {'network_embedding': ['NoEmbedding']} |
544 | 518 | # Search for a good configuration
|
545 | 519 | estimator = TabularClassificationTask(
|
546 | 520 | backend=backend,
|
547 | 521 | resampling_strategy=HoldoutValTypes.holdout_validation,
|
548 |
| - include_components=include |
549 | 522 | )
|
550 | 523 |
|
551 | 524 | with unittest.mock.patch.object(estimator, '_do_dummy_prediction', new=dummy_do_dummy_prediction):
|
@@ -584,16 +557,9 @@ def test_portfolio_selection_failure(openml_id, backend, n_samples):
|
584 | 557 | X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
|
585 | 558 | X, y, random_state=1)
|
586 | 559 |
|
587 |
| - include = None |
588 |
| - # for python less than 3.7, learned entity embedding |
589 |
| - # is not able to be stored on disk (only on CI) |
590 |
| - if sys.version_info < (3, 7): |
591 |
| - include = {'network_embedding': ['NoEmbedding']} |
592 |
| - # Search for a good configuration |
593 | 560 | estimator = TabularClassificationTask(
|
594 | 561 | backend=backend,
|
595 | 562 | resampling_strategy=HoldoutValTypes.holdout_validation,
|
596 |
| - include_components=include |
597 | 563 | )
|
598 | 564 | with pytest.raises(FileNotFoundError, match=r"The path: .+? provided for 'portfolio_selection' "
|
599 | 565 | r"for the file containing the portfolio configurations "
|
|
0 commit comments