-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
SLEP006: globally setting request values #26050
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
Comments
What is the thinking about why we need to ask users to add code like sklearn.set_fit_request(sample_weight=True)
sklearn.set_score_request(sample_weight=True) to enable this compared to it being the default, with an option to turn it off via: sklearn.set_fit_request(sample_weight=False)
# and/or
sklearn.set_score_request(sample_weight=False) The reason I am asking is that I'd expect the case of "I have weights and want it to just work" being more frequent and hence default on instead of default off. |
Having the default to be sample weight requested everywhere results in wrong practices. For instance, We will work on a sane default value for requests, which we'll develop as a part of the |
What are these wrong practices? Why would I not want |
You probably don't want the to consume and route them. And by default they'd do both with this setting. |
One of the issues raised in #25776 and #23928 is about a code such as following to work under SLEP6:
or
without having to change the code, or w/o having to write too much boilerplate code, or w/o having to explicitly set request values for
sample_weight
for these usual usecases.In order to allow the above pattern, the proposal is to allow users to set request values globally. These values can either be set as a configuration, or via dedicated methods. The user code at the end would look like:
What the above code does, is to set he default value to
REQUESTED
instead ofERROR_IF_PASSED
forsample_weight
, onfit
andscore
methods / scorers everywhere.API
A generic way to achieve this would be to set global default request values, on any method, for any metadata, which can generalize to
groups
and other metadata present in third party libraries.Alternatively, we could only allow this for
sample_weight
(I rather not do this), and do it with something like:or if we don't want to distinguish between methods:
My proposal would be:
which follows the API on the estimator level, except that here we're setting it on the library scope.
Context Manager
An addition to the above API, we can provide a context manager for the same purpose. If we expose this through a config, it's automatically done via
config_context
. If we follow another API, we can also provide the corresponding context managers.Effect on SLEP6's examples
Here we look at how the examples in the SLEP would change.
Nested Grouped Cross Validation
becomes:
And users can still override the default global value at the estimator level, for example, the next example:
becomes
Unweighted Feature selection
Here there's no request value for
SelectKBest
set since it doesn't supportsample_weight
:it becomes:
More advanced use cases with aliased routing
Aliased routing is not supported at the moment, and if the user wants to pass different sample weights to different objects, they'll need to use the verbose API.
Open Questions
sample_weight="auto"
We also talked about good default request values for
sample_weight
specifically (#25776 (comment)), to allow users to follow our recommendations. This would be enabled by doing something like:or more explicitly
This would enable recommended routing, whatever we decide that to be. This is NOT a blocker for releasing SLEP6 and can be implemented after it's released, and recommendations are subject to change, and we tell users that they can change.
There shall be a separate issue to talk about the default values and how the end user API should look like. It is only mentioned here to give context on what we plan to do.
cc @scikit-learn/core-devs
The text was updated successfully, but these errors were encountered: