Skip to content
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

PERF Get rid of intermediate array in binary_log_loss #17932

Merged
merged 1 commit into from Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/whats_new/v0.24.rst
Expand Up @@ -283,7 +283,7 @@ Changelog

- |Efficiency| Neural net training and prediction are now a little faster.
:pr:`17603`, :pr:`17604`, :pr:`17606`, :pr:`17608`, :pr:`17609`, :pr:`17633`,
:pr:`17661` by :user:`Alex Henrie <alexhenrie>`.
:pr:`17661`, :pr:`17932` by :user:`Alex Henrie <alexhenrie>`.

- |Enhancement| Avoid converting float32 input to float64 in
:class:`neural_network.BernoulliRBM`.
Expand Down
4 changes: 2 additions & 2 deletions sklearn/neural_network/_base.py
Expand Up @@ -220,8 +220,8 @@ def binary_log_loss(y_true, y_prob):
"""
eps = np.finfo(y_prob.dtype).eps
y_prob = np.clip(y_prob, eps, 1 - eps)
return -(xlogy(y_true, y_prob) +
xlogy(1 - y_true, 1 - y_prob)).sum() / y_prob.shape[0]
return -(xlogy(y_true, y_prob).sum() +
xlogy(1 - y_true, 1 - y_prob).sum()) / y_prob.shape[0]


LOSS_FUNCTIONS = {'squared_loss': squared_loss, 'log_loss': log_loss,
Expand Down