-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Add pprint for estimators - continued #11705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
acc3732
c99c85a
a2ef6dc
fd543e8
64932cd
df281fb
05df6ad
01db0c6
89ee958
f6450db
2079d78
1a3c380
cd39e8d
d45bd0a
30431a7
6a547d6
d82afee
4a98b5a
5a64453
4f8c450
68d1806
9afcd0b
07914e4
54ff3a8
4a3bb04
eb9a171
8b5b283
f0ed05f
e785d22
b64258e
14eac3b
2932be8
6e62480
191b421
4942b97
7560f24
5e23560
19073c7
92ecd48
9170019
69fd6b4
43216c8
826c296
99a1634
1a8a0ec
5ab28f9
90f9543
f2808a1
ab639ae
c48d713
4e06804
affaae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
================================= | ||
Compact estimator representations | ||
================================= | ||
|
||
This example illustrates the use of the print_changed_only global parameter. | ||
|
||
Setting print_changed_only to True will alterate the representation of | ||
estimators to only show the parameters that have been set to non-default | ||
values. This can be used to have more compact representations. | ||
""" | ||
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='warn', 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') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
|
||
_global_config = { | ||
'assume_finite': bool(os.environ.get('SKLEARN_ASSUME_FINITE', False)), | ||
'working_memory': int(os.environ.get('SKLEARN_WORKING_MEMORY', 1024)) | ||
'working_memory': int(os.environ.get('SKLEARN_WORKING_MEMORY', 1024)), | ||
'print_changed_only': False, | ||
} | ||
|
||
|
||
|
@@ -20,7 +21,8 @@ def get_config(): | |
return _global_config.copy() | ||
|
||
|
||
def set_config(assume_finite=None, working_memory=None): | ||
def set_config(assume_finite=None, working_memory=None, | ||
print_changed_only=None): | ||
"""Set global scikit-learn configuration | ||
|
||
.. versionadded:: 0.19 | ||
|
@@ -43,11 +45,21 @@ def set_config(assume_finite=None, working_memory=None): | |
|
||
.. versionadded:: 0.20 | ||
|
||
print_changed_only : bool, optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this be clearer as print_defaults? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so because the meaning of the parameter is really "only show the parameters that don't have their default values, i.e. the ones that are changed" "print_defaults" would mean something quite different. Maybe "hide_defaults"? Or "print_hide_defaults"? |
||
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 | ||
""" | ||
if assume_finite is not None: | ||
_global_config['assume_finite'] = assume_finite | ||
if working_memory is not None: | ||
_global_config['working_memory'] = working_memory | ||
if print_changed_only is not None: | ||
_global_config['print_changed_only'] = print_changed_only | ||
|
||
|
||
@contextmanager | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adrinjalali I took the liberty to fix this