Print Estimator Name in SkLearn

I think you are looking for estimator.__class__.__name__ i.e.:

from sklearn.linear_model import LogisticRegression

def print_estimator_name(estimator):
    print(estimator.__class__.__name__)

#Expected Outcome:
print_estimator_name(LogisticRegression())

I have an alternative method. Get the object name, convert to str, get foremost child class with split("."), and finally strip off unwanted chars

str(type(clf)).split(".")[-1][:-2]

This work for me in SKLearn, XGBoost, and LightGBM

print(f'Acc: {pred:0.5f} for the {str(type(clf)).split(".")[-1][:-2])}')
Acc: 0.7159443 : DecisionTreeClassifier
Acc: 0.7572368 : RandomForestClassifier
Acc: 0.7548593 : ExtraTreesClassifier
Acc: 0.7416970 : XGBClassifier
Acc: 0.7582540 : LGBMClassifier