NotFittedError#

异常 sklearn.exceptions.NotFittedError[源代码]#

在估计器拟合前使用时抛出的异常类。

此类继承自 ValueError 和 AttributeError,以帮助进行异常处理和保持向后兼容性。

示例

>>> from sklearn.svm import LinearSVC
>>> from sklearn.exceptions import NotFittedError
>>> try:
...     LinearSVC().predict([[1, 2], [2, 3], [3, 4]])
... except NotFittedError as e:
...     print(repr(e))
NotFittedError("This LinearSVC instance is not fitted yet. Call 'fit' with
appropriate arguments before using this estimator."...)

在版本 0.18 中更改: 从 sklearn.utils.validation 移动。