Загрузка
Pytest specific decorator for parametrizing estimator checks.
Checks are categorised into the following groups:
API checks: a set of checks to ensure API compatibility with scikit-learn. Refer to https://scikit-learn.org/dev/developers/develop.html a requirement of scikit-learn estimators.
legacy: a set of checks which gradually will be grouped into other categories.
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.
Whether to include legacy checks. Over time we remove checks from this category and move them into their specific category.
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.
Whether to run checks in xfail strict mode. If True, checks that are expected to fail but actually pass will lead to a test failure. If False, unexpectedly passing tests will be marked as xpass. If None, the default pytest behavior is used.
pytest.mark.parametrize>>> 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)