-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Fix underflow issues due to float precision #19472
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
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.
Thanks for the report and fix, it looks reasonable to me, especially as P
also uses a (temporary) double precision. I guess we can also use double precision in the constants at the top of the file, although it might not change much for Cython.
Can you also add a bugfix entry in doc/whats_new/v1.0.rst
?
Thanks @TomDLT. I added the description to I was not aware that the next release will be 1.0! Wow! Huge milestone. When is this release planned? |
Don't know :) |
Co-authored-by: Tom Dupré la Tour <tom.dupre-la-tour@m4x.org>
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.
I guess we can also use double precision in the constants at the top of the file, although it might not change much for Cython.
Do you know if it makes a difference ?
I don't think it will change anything. These constants are only used in expressions like this It won't hurt to change them to double either, so if you prefer I can do it, but I think it should have no effect. |
That's what I thought, I have no preference. |
Thanks a lot for your help! Do I need to do anything here anymore? Like request further approvals or anything? This is my first PR to sklearn so I am not very familiar with the process. |
Congrats for your first PR ! Also thanks for taking the time to improve the scikit-learn's implementation of tSNE. It might not be the best implementation, but it is likely used by many, so any improvement is very welcome !
(from here) You just need to wait a moment for other core developers to approve this PR. This might take some time since most developers have limited time to do code reviews. If it takes too much time, you can try to ping specific developers. |
Also, ideally your PR should include a unit test, maybe based on the example you gave in the original issue. |
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. I agree with @TomDLT that adding a test would be nice (in sklearn/manifold/tests/test_t_sne.py
).
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
OK. Let me try to add a test. |
could you move it in a dedicated test, maybe named |
@TomDLT @jeremiedbb Test added and all checks passed! |
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. I confirm that the test fails on main. Thanks @dkobak
Fixes #19471 by replacing
float
s withdouble
s in the Cython code for_binary_search_perplexity()
.