-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Open
Labels
Description
Describe the bug
I maintain the scikit-learn compatible projects fastcan and use check_estimator to check its compatibility.
When I use sklearn.utils.column_or_1d to validate the argument y of fit, the error message of None input is accepted by check_estimator.
However, when I use sklearn.utils._param_validation.validate_params, the error message of None input is invalid for check_estimator.
Both column_or_1d and validate_params are standard ways to validate the function arguments. The error messages of both should be valid.
Steps/Code to Reproduce
from sklearn.utils import column_or_1d
from sklearn.utils._param_validation import validate_params
from sklearn.utils.estimator_checks import check_requires_y_none
from sklearn.base import BaseEstimator
class ClassA(BaseEstimator):
@validate_params(
{
"X": ["array-like"],
"y": ["array-like"],
},
prefer_skip_nested_validation=True,
)
def fit(self, X, y):
return self
class ClassB(BaseEstimator):
@validate_params(
{
"X": ["array-like"],
},
prefer_skip_nested_validation=True,
)
def fit(self, X, y):
column_or_1d(y)
return self
A = ClassA()
B = ClassB()Expected Results
check_requires_y_none("ClassA", A) # Pass
check_requires_y_none("ClassA", B) # PassActual Results
check_requires_y_none("ClassA", A) # Fail
check_requires_y_none("ClassA", B) # PassVersions
sklearn: 1.8.0