Why was the output of "fit" method changed in scikit-learn 0.23?

Viewed 46

For example

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import ShuffleSplit
from sklearn.linear_model import LogisticRegression

data = load_breast_cancer()
X = data.data
y = data.target

ss = ShuffleSplit(n_splits=1,
                  train_size=0.8,
                  test_size=0.2,
                  random_state=0)

train_index, test_index = next(ss.split(X, y))

X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]

clf = LogisticRegression()
clf.fit(X_train, y_train)

In the case of the above code, in version 0.22, the output results in the following.

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

But for version 0.23 it will be as follows.

LogisticRegression()

Why did scikit-learn change to this specification in upgrading from version 0.22 to version 0.23?

1 Answers

See the definition of set_config method. Especially:

print_changed_only : bool, default=None If True, only the parameters that were set to non-default values will be printed when printing an estimator. For example, print(SVC()) while True will only print 'SVC()' while the default behaviour would be to print 'SVC(C=1.0, cache_size=200, ...)' with all the non-changed parameters. .. versionadded:: 0.21

To return old behavior back try prior initiating estimator:

from sklearn import set_config
set_config(print_changed_only=False)

or change source (not recommended, only if you understand what you're doing)

Related