NotFittedError#

exception sklearn.exceptions.NotFittedError[source]#

如果在拟合前使用估算器,则引发的异常类。

This class inherits from both ValueError and AttributeError to help with exception handling and backward compatibility.

示例

>>> 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."...)

Changed in version 0.18: Moved from sklearn.utils.validation.