mlearner version: 0.2.0
check_is_fitted
check_is_fitted(estimator, attributes, msg=None, all_or_any=
Perform is_fitted validation for estimator. Checks if the estimator is fitted by verifying the presence of "all_or_any" of the passed attributes and raises a NotFittedError with the given message. Parameters
-
estimator
: estimator instance.estimator instance for which the check is performed.
-
attributes
: attribute name(s) given as string or a list/tuple of stringsEg.:
["coef_", "estimator_", ...], "coef_"
-
msg
: stringThe 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_any
: callable, {all, any}, default allSpecify whether all or any of the given attributes must exist. Returns
None Raises
NotFittedError If the attributes are not found.