exceptions.NotFittedError

class sklearn.exceptions.NotFittedError [source]

Exception class to raise if estimator is used before fitting.

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

Examples

1
2
3
4
5
6
7
8
>>> 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',)

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

doc_scikit_learn
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.