Pytest specific decorator for parametrizing estimator checks.
Checks are categorised into the following groups:
The id of each check is set to be a pprint version of the estimator and the name of the check with its keyword arguments. This allows to use pytest -k to specify which tests to run:
pytest test_check_estimators.py -k check_estimators_fit_returns_self
Estimators to generated checks for.
Changed in version 0.24: Passing a class was deprecated in version 0.23, and support for classes was removed in 0.24. Pass an instance instead.
Added in version 0.24.
Whether to include legacy checks. Over time we remove checks from this category and move them into their specific category.
Added in version 1.6.
A callable that takes an estimator as input and returns a dictionary of the form:
{
"check_name": "my reason",
}
Where "check_name" is the name of the check, and "my reason" is why the check fails. These tests will be marked as xfail if the check fails.
Added in version 1.6.
pytest.mark.parametrize
See also
check_estimatorCheck if estimator adheres to scikit-learn conventions.
>>> from sklearn.utils.estimator_checks import parametrize_with_checks >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.tree import DecisionTreeRegressor
>>> @parametrize_with_checks([LogisticRegression(), ... DecisionTreeRegressor()]) ... def test_sklearn_compatible_estimator(estimator, check): ... check(estimator)
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.utils.estimator_checks.parametrize_with_checks.html