estimator_checks_generator#

sklearn.utils.estimator_checks.estimator_checks_generator(estimator, *, legacy: bool = True, expected_failed_checks: dict[str, str] | None = None, mark: Literal['xfail', 'skip', None] = None, xfail_strict: bool | None = None)[source]#

迭代地生成估算器的所有可调用检查。

此函数被 parametrize_with_checkscheck_estimator 使用,用于为估计器生成所有检查可调用对象。在大多数情况下,应使用这些函数。在实现自定义等效功能时,请参考它们的源代码以了解 estimator_checks_generator 的预期用途。

版本 1.6 中新增。

参数:
estimator估计器对象

要为其生成检查的估计器实例。

legacybool, default=True

是否包含遗留检查。随着时间的推移,我们会从这个类别中删除检查,并将它们移动到特定的类别中。

expected_failed_checksdict[str, str], default=None

对于预期失败的检查,格式为 {check_name: reason} 的字典。

mark{“xfail”, “skip”} or None, default=None

是否将预期失败的检查标记为 xfail (pytest.mark.xfail) 或 skip。将测试标记为“skip”是通过将检查包装在一个引发 SkipTest 异常的函数中来完成的。

xfail_strictbool, default=None

是否以 xfail 严格模式运行检查。除非 mark="xfail",否则此选项将被忽略。如果为 True,则预期失败但实际通过的检查将导致测试失败。如果为 False,意外通过的测试将被标记为 xpass。如果为 None,则使用默认的 pytest 行为。

1.8 版本新增。

返回:
estimator_checks_generatorgenerator

生成器,生成 (estimator, check) 元组。