sklearn.utils.validation.check_is_fitted

sklearn.utils.validation.check_is_fitted(estimator, attributes='deprecated', msg=None, all_or_any='deprecated')[source]

Perform is_fitted validation for estimator.

Checks if the estimator is fitted by verifying the presence of fitted attributes (ending with a trailing underscore) and otherwise raises a NotFittedError with the given message.

Parameters
estimatorestimator instance.

estimator instance for which the check is performed.

attributesdeprecated, ignored

Deprecated since version 0.22: attributes is deprecated, is currently ignored and will be removed in 0.23.

msgstring

The default error message is, “This %(name)s instance is not fitted yet. Call ‘fit’ with appropriate arguments before using this method.”

For custom messages if “%(name)s” is present in the message string, it is substituted for the estimator name.

Eg. : “Estimator, %(name)s, must be fitted before sparsifying”.

all_or_anydeprecated, ignored

Deprecated since version 0.21: all_or_any is deprecated, is currently ignored and will be removed in 0.23.

Returns
None
Raises
NotFittedError

If the attributes are not found.