How to obtain only the name of a model’s object in SciKitLearn?

You can do this:

model_name = type(model).__name__

as in

Python 3.5.5 | packaged by conda-forge | (default, Jul 23 2018, 23:45:11) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.linear_model import LinearRegression
>>> model = LinearRegression()
>>> model_name = type(model).__name__
>>> print(model_name)
LinearRegression

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)