8000 replace log with log1p by meetnaren · Pull Request #11424 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

replace log with log1p #11424

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

Merged
merged 2 commits into from
Jul 4, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/modules/model_evaluation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Here is an example of building custom scorers, and of using the
>>> import numpy as np
>>> def my_custom_loss_func(y_true, y_pred):
... diff = np.abs(y_true - y_pred).max()
... return np.log(1 + diff)
... return np.log1p(diff)
...
>>> # score will negate the return value of my_custom_loss_func,
>>> # which will be np.log(2), 0.693, given the values for X
Expand Down
2 changes: 1 addition & 1 deletion sklearn/metrics/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def mean_squared_log_error(y_true, y_pred,
raise ValueError("Mean Squared Logarithmic Error cannot be used when "
"targets contain negative values.")

return mean_squared_error(np.log(y_true + 1), np.log(y_pred + 1),
return mean_squared_error(np.log1p(y_true), np.log1p(y_pred),
sample_weight, multioutput)


Expand Down
0