sklearn.exceptionsNotFittedError?

class sklearn.exceptions.NotFittedError

[源碼]

如果在擬合之前使用了估計器,則引發異常。

這個類繼承了ValueError和AttributeError以幫助實現異常處理和向后兼容性。

屬性 說明
args

示例

>>> 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轉移。

方法

方法 說明
with_traceback() Exception.with_traceback(tb) – set self.traceback to tb and return self.
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.