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 | 如果找不到屬性。 |