sklearn.utils.estimator_checks.parametrize_with_checks?
sklearn.utils.estimator_checks.parametrize_with_checks(estimators)
Pytest特定的裝飾器,用于參數估計器檢查。
每個檢查的id設置為估算器的pprint版本,并帶有其關鍵字參數和檢查的名稱。 這允許使用pytest -k來指定要運行的測試:
pytest test_check_estimators.py -k check_estimators_fit_returns_s
參數 | 說明 |
---|---|
estimators | list of estimators objects or classes 用于生成檢查的估計量 從0.23版開始不推薦使用:從0.23版開始不推薦使用傳遞類,因此0.24版不支持該類。 而是傳遞一個實例。 |
返回值 | 說明 |
---|---|
decorator | 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)