check_estimator() not respecting custom estimator constraints via check_estimators_fit_returns_self() #23885
Labels
Bug
Developer API
Third party developer API related
module:test-suite
everything related to our tests
Describe the bug
check_estimators_fit_returns_self() does not pass with n_feature constraints
Building a custom estimator extending BaseEstimator with certain constraints such as:
Example of constraints in the test.
The input and output of the estimator results in error thrown within
check_estimator
.It appears that the tests run by
check_estimator
still check with input data with n_features = 2 for instance. Thus, the check_array with the above constraints will throw an error. This is not limited to the number of features but also whether force_all_finite allows nan or not. Some tests check with this value as True.The test
check_estimators_fit_returns_self()
generates blobs with n_features = 2. Thus, this test will fail for any estimator that has feature_constraints != 2.See: https://github.com/scikit-learn/scikit-learn/blob/baf0ea25d/sklearn/utils/estimator_checks.py#L2581-L2595
TL:DR
It appears that despite setting certain constraints of the input X,y. Such as
force_all_finite
andensure_min_features
. Some tests still use the default values for thecheck_array
function and fail the check_estimator test due to this.The full error
Full error
Reproduction
Let's create a very basic estimator which only takes 3 features. Then run check_estimator on this.
Error produced:
ValueError: Found array with 2 feature(s) (shape=(21, 2)) while a minimum of 3 is required.
Steps/Code to Reproduce
Run a check_estimator on an instance of this dummy estimator
Expected Results
Passing all tests.
Actual Results
Versions
The text was updated successfully, but these errors were encountered: