-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Option to suppress validation for finiteness #7548
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
Conversation
12dd724
to
1cbf18b
Compare
And perhaps in the future we will add more validation suppression as a result of this flag (e.g. some of the stuff in Is it worth using this option, for instance, to assume labels are already encoded in 0 to n_classes - 1? (or because this is a fit-time concern, is that premature optimisation?) |
Currently the variable name is a bit to generic for my taste. It sounds like it suppresses all validation. Maybe |
|
I've renamed to |
Sounds good. To me |
LGTM. I'd like to have @GaelVaroquaux sign off on this if he has time. |
The documentation is quite hard to find right now, but I'm not sure what a better place would be. |
I'm happy to change to ASSUME. The difference is that often you assume something but still check; when you presume something, you go with that presumption blindly. No hurry here. |
I like PRESUME_FINITE. |
But we do have |
Small concern about putting the check inside |
@TomDLT I'm not sure I understand your concern. We should document that the behavior is overwritten by the flag, but it doesn't change any current behavior. |
I think the idea that we're assuming rather than asserting finiteness when On 15 October 2016 at 04:04, Andreas Mueller notifications@github.com
|
have added a note to docs. |
Are we still waiting for @GaelVaroquaux to comment on that one? |
LGTM. One think that would be good would be to add a contextmanager to do that. I fear Ill-written code that suppresses validation in more places that it would like. |
Do you foresee |
Do you foresee with sklearn.set_validation analogous to np.seterr?
Yes, I think that would be the right way to do it.
|
I'm fine with either way, slightly leaning to |
Yes, I'll get back to it some time soon! I know, it'll be a nice feature to have. |
@amueller, my concern with that first example is that introducing a context manger into I get the documentation simplicity of your approach. It makes sense in numpy where the errstate is homogeneous in the types of settings it's dealing with; and perhaps in matplotlib where the config is everything. Here we only have one setting, and as far as I can tell, configurations are unlikely to have much to do with each other. A context, except at the outermost level of library invocation, is likely to set only few of the params. But this is almost entirely philosophy and I should probably just adopt what you suggest. |
You currently only have one global configuration 😈. If you expect it to stay that way, then why aren't these called Users are very clever and will do all sorts of 'interesting' things (and will not be persuaded by 'do not do that', and documenting what not to do just gives some users ideas!) so even if sklearn never writes functions like this, some downstream library will. |
Shrug. I'll do it your way. Not entirely convinced it has real benefits.
…On 21 December 2016 at 02:51, Thomas A Caswell ***@***.***> wrote:
You *currently* only have one global configuration 😈. If you expect it
to stay that way, then why aren't these called ignore_nan_context and
set_ignore_nan_state, etc?
Users are very clever and *will* do all sorts of 'interesting' things
(and will not be persuaded by 'do not do that', and *documenting* what
not to do just gives some users ideas!) so even if sklearn never writes
functions like this, some downstream library will.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7548 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz68n7ACxZcLzLNodr2wZTA0TSFJFhks5rJ_mMgaJpZM4KL6yC>
.
|
Sorry if I was arguing too forcefully or was out of line. I do not know the audience here (but do know I am the peanut gallery!). |
Arguing too forcefully probably doesn't exist for me ;)
…On 21 December 2016 at 14:33, Thomas A Caswell ***@***.***> wrote:
Sorry if I was arguing too forcefully or was out of line. I do not know
the audience here (but do know I am the peanut gallery!).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7548 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz6_p2bsgDGrePqvmtpdNPEtJhNEkNks5rKJ4MgaJpZM4KL6yC>
.
|
Pushed conformant changes |
@amueller, I assume this still has your +1? Another review? |
I'll review again and ping @GaelVaroquaux to check it out |
import os | ||
from contextlib import contextmanager as _contextmanager | ||
|
||
_ASSUME_FINITE = bool(os.environ.get('SKLEARN_ASSUME_FINITE', False)) |
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.
If we want to add more config in the future, don't we want them to be bundled in a dictionary?
still +1 but maybe have a the global variable be a dict if we want to add an option for the repr? |
|
||
Parameters | ||
---------- | ||
assume_finite : bool, optional |
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.
bad param docstring
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.
How so? Because I should say that it needs to be specified by name?
The point here is that the user always has the option to change, but can leave things unchanged Too
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.
forget it
The global variables is private so its structure can change
…On 8 Jun 2017 1:07 am, "Andreas Mueller" ***@***.***> wrote:
still +1 but maybe have a the global variable be a dict if we want to add
an option for the repr?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7548 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz6whM1-OzgvYU7Tbg1HUHb8hkqgjXks5sBryggaJpZM4KL6yC>
.
|
Ok I'll do that in my PR ;) |
does that mean this one will get merged? :)
can i still count nelle's approval above?
…On 8 Jun 2017 9:22 pm, "Andreas Mueller" ***@***.***> wrote:
Ok I'll do that in my PR ;)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7548 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz63mKh6xNJ8WJBCbHrS6v2sGcusZ5ks5sB9mCgaJpZM4KL6yC>
.
|
looks great. @amueller green button ? |
yes ;) |
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
* ENH add suppress validation option * TST skip problematic doctest * Rename SUPPRESS_VALIDATION to PRESUME_FINITE * Change PRESUME_ to ASSUME_ for convention's sake * DOC add note regarding assert_all_finite * ENH add set_config context manager for ASSUME_FINITE * Make ASSUME_FINITE private and provide get_config * Fix ImportError due to incomplete change in last commit * TST/DOC tests and more cautious documentation for set_config * DOC what's new entry for validation suppression * context manager is now config_context; set_config affects global config * Rename missed set_config to config_context * Fix mis-named test * Mention set_config in narrative docs * More explicit about limmited restoration of context * Handle case where error raised in config_context * Reset all settings after exiting context manager
Fixes #1363. I'm not sure if this is the best way to make a global configuration parameter available, or the best place to document it.