-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
API Gaussian Process: change default behavior of sample_y
#25789
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
base: main
Are you sure you want to change the base?
API Gaussian Process: change default behavior of sample_y
#25789
Conversation
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.
Thank you for the PR! Can you updated sklearn/gaussian_process/tests/test_gpr.py
suc that
- All calls to
sample_y
hasrandom_state=0
. This keeps the test deterministic when running on different platforms. - Add a new test to make check that the new warning is raised.
sample_y
sample_y
a764914
to
4472e61
Compare
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.
Thank you for the update!
May you add a change log entry in doc/whats_new/v1.3.rst
with tag |API|
that describes the change?
Also sklearn/gaussian_process/tests/test_gpr.py
still needs to be updated by setting sample_y(..., random_state=0)
so the tests are deterministic between platforms.
Hey, just so I completely understand. You want me to go through |
4472e61
to
bc327f5
Compare
I see that the doc building failed. |
bc327f5
to
a17a478
Compare
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.
the calls to sample_y calls such that they explicitly set the the random_state keyword to 0?
Yup. It looks like you did it already.
I have some minor comments, otherwise this PR looks ready to go!
The `random_state` argument was set to `0` forceing `sample_y` to always return the same gaussian process samples. This is contrary to the expected behavior most people have from working with random number generating libraries such as numpy and scipy. Changing the default parameter to `None` will make the behavior of `sample_y` conform to the usual expectation a user. Updated `test_gpr.py` so that all calls to `sample_y` are passed `random_state=0` to enusre deterministic testing.
a17a478
to
6fe269b
Compare
Thanks for all the help in getting me through this PR! |
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.
LGTM
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.
Also, please submit a commit with [doc build]
in the commit message so that we make sure there are no warnings as a result of this in the documentation.
"The default value of random_state will change from" | ||
+ " 0 to None in 1.5", |
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.
We should tell users how to silence the warning. Something like the following text:
"The default value of random_state will change from" | |
+ " 0 to None in 1.5", | |
"The default value of random_state will change from" | |
" 0 to None in version 1.5. Explicitly set a value for `random_state` " | |
"to silence this warning", |
Sorry for delay on this. |
@ominusliticus sorry, this slipped through and didn't see your message. Our changelog is quite different now, it needs to follow the new template (separate file for each PR). Let me know if you still have time to work on this. |
The
random_state
argument was set to0
forceingsample_y
to always return the same gaussian process samples.This is contrary to the expected behavior most people have from working with random number generating libraries such as numpy and scipy. Changing the default parameter to
None
will make the behavior ofsample_y
conform to the usual expectation a user.Reference Issues/PRs
Fixes #25767
What does this implement/fix? Explain your changes.
Changes default parameter
random_state
fromGaussianProcessRegressor
from0
toNone
to make it behave like a randomnumber generator (RNG) by default, conforming with all other RNG APIs.
Any other comments?