def is_fitted(estimator):
    """
    Checks if a scikit-learn estimator/transformer has already been fit.


    Parameters
    ----------
    estimator: scikit-learn estimator (e.g. RandomForestClassifier)
        or transformer (e.g. MinMaxScaler) object


    Returns
    -------
    Boolean that indicates if ``estimator`` has already been fit (True) or not (False).
    """

    attrs = [v for v in vars(estimator) if v.endswith("_") and not v.startswith("__")]

    return len(attrs) != 0