8000 MNT replace log with log1p (#11424) · scikit-learn/scikit-learn@6f9a8df · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f9a8df

Browse files
meetnarenjnothman
authored andcommitted
MNT replace log with log1p (#11424)
1 parent 7d4fef3 commit 6f9a8df

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
8000 lines changed

doc/modules/model_evaluation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Here is an example of building custom scorers, and of using the
176176
>>> import numpy as np
177177
>>> def my_custom_loss_func(y_true, y_pred):
178178
... diff = np.abs(y_true - y_pred).max()
179-
... return np.log(1 + diff)
179+
... return np.log1p(diff)
180180
...
181181
>>> # score will negate the return value of my_custom_loss_func,
182182
>>> # which will be np.log(2), 0.693, given the values for X

sklearn/metrics/regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def mean_squared_log_error(y_true, y_pred,
314314
raise ValueError("Mean Squared Logarithmic Error cannot be used when "
315315
"targets contain negative values.")
316316

317-
return mean_squared_error(np.log(y_true + 1), np.log(y_pred + 1),
317+
return mean_squared_error(np.log1p(y_true), np.log1p(y_pred),
318318
sample_weight, multioutput)
319319

320320

0 commit comments

Comments
 (0)
0