压缩估算器表示¶
此案例说明了print_changed_only全局参数的用法。
将print_changed_only设置为True,估算器会交替显示,因此,仅仅已设置为非默认值的参数会被展现。这可以实现更紧凑地成果表现。
输出:
Default representation:
LogisticRegression(penalty='l1')
With changed_only option:
LogisticRegression(penalty='l1')
输入:
print(__doc__)
from sklearn.linear_model import LogisticRegression
from sklearn import set_config
lr = LogisticRegression(penalty='l1')
print('Default representation:')
print(lr)
# LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
# intercept_scaling=1, l1_ratio=None, max_iter=100,
# multi_class='auto', n_jobs=None, penalty='l1',
# random_state=None, solver='warn', tol=0.0001, verbose=0,
# warm_start=False)
set_config(print_changed_only=True)
print('\nWith changed_only option:')
print(lr)
# LogisticRegression(penalty='l1')
脚本的总运行时间:0分0.003秒。