-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] clone test of dummy estimator (#1129)
* [FIX] clone test of dummy estimator * [FIX] flake8
- Loading branch information
1 parent
79627e1
commit 0982410
Showing
2 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import numpy as np | ||
|
||
import pytest | ||
|
||
from sklearn.base import clone | ||
from sklearn.datasets import make_classification, make_regression | ||
from sklearn.utils.validation import check_is_fitted | ||
|
||
from autosklearn.evaluation.abstract_evaluator import MyDummyClassifier, MyDummyRegressor | ||
|
||
|
||
@pytest.mark.parametrize("task_type", ['classification', 'regression']) | ||
def test_dummy_pipeline(task_type): | ||
if task_type == 'classification': | ||
estimator_class = MyDummyClassifier | ||
data_maker = make_classification | ||
elif task_type == 'regression': | ||
estimator_class = MyDummyRegressor | ||
data_maker = make_regression | ||
else: | ||
pytest.fail(task_type) | ||
|
||
estimator = estimator_class(config=1, random_state=np.random.RandomState(42)) | ||
X, y = data_maker() | ||
estimator.fit(X, y) | ||
check_is_fitted(estimator) | ||
|
||
assert np.shape(X)[0] == np.shape(estimator.predict(X))[0] | ||
|
||
# make sure we comply with scikit-learn estimator API | ||
clone(estimator) |