import six


def _get_context(estimator=None):
    """Get context name for warning messages."""
    if estimator is not None:
        if isinstance(estimator, six.string_types):
            estimator_name = estimator.lower()
        else:
            estimator_name = estimator.__class__.__name__.lower()

        estimator_name = "[%s] " % estimator_name
    else:
        estimator_name = ""

    return estimator_name