Toggle Menu
Prev Up Next

scikit-learn 1.3.2
Other versions

Please cite us if you use the software.

# `sklearn.exceptions`.NotFittedError

class sklearn.exceptions.NotFittedError

  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.

  Attributes:
    args
    `name`

      attribute name

    `obj`

      object

  Examples

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

  Methods

  `add_note` | Exception.add_note(note) -- add a note to the exception
  `with_traceback` | Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

  add_note()

    Exception.add_note(note) – add a note to the exception

  name

    attribute name

  obj

    object

  with_traceback()

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