-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Use scipy.special.xlogy to avoid indefinite limit in 0 for x*log(y) #12915
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
@@ -297,7 +297,7 @@ def test_multilabel_classification(): | |||
max_iter=150, random_state=0, activation='logistic', | |||
learning_rate_init=0.2) | |||
mlp.fit(X, y) | |||
assert_equal(mlp.score(X, y), 1) | |||
assert_greater(mlp.score(X, y), 0.97) |
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.
This fails otherwise, as the score is 0.98 in this case.
Testing that mean test accuracy is exactly 1 on this random dataset with those parameters doesn't sound too robust, and the change of the numerical accuracy in log loss might have been enough to break this condition.
I guess we don't need tests and what's new here. |
…r x*log(y) (scikit-learn#12915)" This reverts commit 6b476ca.
…r x*log(y) (scikit-learn#12915)" This reverts commit 6b476ca.
x*log(y)
is undefined when bothx
andy
are zero,currently we avoid this by clipping
x
andy
to a very small value (e.g. 1e-10) instead of 0.A cleaner solution is to use
scipy.special.xlogy
,which produces the correct limit in 0 and has a comparable performance otherwise.