__sklearn_is_fitted__ as Developer API
The __sklearn_is_fitted__ method is a convention used in scikit-learn for
checking whether an estimator object has been fitted or not. This method is
typically implemented in custom estimator classes that are built on top of
scikit-learn’s base classes like BaseEstimator or its subclasses.
Developers should use check_is_fitted
at the beginning of all methods except fit. If they need to customize or
speed-up the check, they can implement the __sklearn_is_fitted__ method as
shown below.
In this example the custom estimator showcases the usage of the
__sklearn_is_fitted__ method and the utility function
as developer APIs. The method checks fitted status
by verifying the presence of the attribute.