-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-2552][MLLIB] stabilize logistic function in pyspark #1493
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
|
Jenkins, test this please. |
|
QA tests have started for PR 1493. This patch merges cleanly. |
|
Jenkins, retest this please. |
|
QA tests have started for PR 1493. This patch merges cleanly. |
|
Jenkins, retest this please. |
|
QA tests have started for PR 1493. This patch merges cleanly. |
|
QA results for PR 1493: |
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.
Better would be
prob = exp(margin)/(1 + exp(margin))because for very small probabilities this computation is essentially doing 1 - 1. For example:
>>> from math import exp
>>> margin = -40
>>> 1 - 1 / (1 + exp(margin))
0.0
>>> exp(margin)/(1 + exp(margin))
4.248354255291589e-18
>>>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.
Yes, that is definitely better. Could you submit a PR? We don't need a JIRA for small changes. Btw, please cache exp(margin) instead of computing it twice.
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.
Sure, pull request here! #1652
Thanks a lot! :-)
to avoid overflow in `exp(x)` if `x` is large. Author: Xiangrui Meng <meng@databricks.com> Closes apache#1493 from mengxr/py-logistic and squashes the following commits: 259e863 [Xiangrui Meng] stabilize logistic function in pyspark
to avoid overflow in
exp(x)ifxis large.