pythonscikit-learnlogistic-regressionhyperparameters

How to display all logistic regression hyperparameters in Scikit-Learn


I imported the logistic regression class provided by Scikit-Learn and then created an object out of it:

from sklearn.linear_model import LogisticRegression
my_lr = LogisticRegression()

The book that I am studying says that when I examine my object I should see the following output:

LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, max_iter=100, multiclass='auto', n_jobs=None, penalty='l2', random_state=None, solver='warn', tool=0.0001, verbose=0, warm_start=False)

However when I run my object in Jupyter Notebook I just see:

LogisticRegression()

Even when I write down all the hyperparameters by myself...

my_new_lr = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, max_iter=100, multiclass='auto', n_jobs=None, penalty='l2', random_state=None, solver='warn', tool=0.0001, verbose=0, warm_start=False)

... I just continue too see this kind output:

LogisticRegression(solver='warn')

This is disappointing because I would expect a lot of hyperparameters in the brackets, in order to see how their values are setted and become familiar with them.


Solution

  • There is model.get_params(deep=True) method. So, this should give you the parameters set:

    print(my_new_lr.get_params())