NotFittedError#
- exception 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 移出。