code: def is_fitted(estimator):
      """
      In order to ensure that we don't call ``fit`` on an already-fitted model,
      this utility function calls ``predict`` on the estimator, returning ``False``
      if it raises a ``sklearn.exceptions.NotFittedError`` and ``True`` otherwise.
  
      NOTE: This is the solution proposed to scikit-yb: https://bit.ly/2LWQxZO (see
      also: https://stackoverflow.com/a/39900933/6552250), though it remains unclear
      how it will perform with sklearn-style Estimators and Transformers from other
      3rd party libraries like Keras, XGBoost, etc.
      """
      try:
          estimator.predict(np.zeros((7, 3)))
      except sklearn.exceptions.NotFittedError:
          return False
      except AttributeError:
          # Some clustering models (LDA, PCA, Agglomerative) don't implement ``predict``
          try:
              check_is_fitted(
                  estimator,
                  [
                      "coef_",
                      "estimator_",
                      "labels_",
                      "n_clusters_",
                      "children_",
                      "components_",
                      "n_components_",
                      "n_iter_",
                      "n_batch_iter_",
                      "explained_variance_",
                      "singular_values_",
                      "mean_",
                  ],
                  all_or_any=any,
              )
              return True
          except sklearn.exceptions.NotFittedError:
              return False
      except Exception:
          # Assume it's fitted, since ``NotFittedError`` wasn't raised
          return True
  
      return True
  
file_path: yellowbrick/yellowbrick/utils/helpers.py
imports: import re
  import inspect
  import sklearn
  import numpy
  from sklearn.pipeline import Pipeline
  from sklearn.utils.validation import check_is_fitted
  from yellowbrick.utils.types import is_estimator
  from yellowbrick.exceptions import YellowbrickTypeError
  from yellowbrick.contrib.wrapper import ContribEstimator
label_desc: Use image node_id 1 for calling a global function with example usage: is_fitted(estimator) and returns: True, False, True, True, False