sklearn.utils.validation.check_is_fitted

sklearn.utils.validation.check_is_fitted(estimator, attributes=None, *, msg=None, all_or_any=<built-in function all>)

源码

对估算器执行is_fitted验证。

通过验证是否存在拟合属性(以下划线结尾)来检查估计量是否拟合,否则通过给定消息引发NotFittedError。

此实用程序旨在由估计器本身在内部使用,通常在其自己的预测/变换方法中使用。

参数 说明
estimator estimator instance.
对其执行检查的估算器实例。
attributes str, list or tuple of str, default=None
以字符串或字符串列表/元组形式给出的属性名称,例如:[“ coef_”,“ estimator_”,...],“ coef_”
msg string
默认错误消息是“此%(name)s实例尚未安装。 在使用此估算器之前,请先使用适当的参数调用“fit”。
all_or_any callable, {all, any}, default all
指定是否必须存在所有或任何给定属性。
返回值 说明
None -
触发
NotFittedError 如果找不到属性。