[go: nahoru, domu]

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

RMSLE (root mean squared log error) #20326

Merged
merged 22 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 17 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
8 changes: 7 additions & 1 deletion doc/whats_new/v1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,19 @@ Changelog
- |Fix| Fixed a bug in :func:`utils.sparsefuncs.mean_variance_axis` where the
precision of the computed variance was very poor when the real variance is
exactly zero. :pr:`19766` by :user:`Jérémie du Boisberranger <jeremiedbb>`.
helper-uttam marked this conversation as resolved.
Show resolved Hide resolved

helper-uttam marked this conversation as resolved.
Show resolved Hide resolved
:mod:`sklearn.validation`
.........................

- |Fix| Support for `np.matrix` is deprecated in
:func:`~sklearn.utils.check_array` in 1.0 and will raise a `TypeError` in
1.2. :pr:`20165` by `Thomas Fan`_.

:mod: `sklearn.metrics`
.......................

- |Feature| :func:`~sklearn.metrics.mean_squared_log_error` now supports
`squared='False'`. :pr:`20326` by :user:`Uttam kumar <helper-uttam>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc CI is failing because of those two warnings:

doc/whats_new/v1.0.rst:587: WARNING: Field list ends without a blank line; unexpected unindent.
doc/whats_new/v1.0.rst:589: WARNING: Mismatch: both interpreted text role prefix and reference suffix. 

The error messages are weird but I suspect this might be caused because there is already an section named sklearn.metrics upper in the same file. The module sections are ordered by alphabetical order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops! I thought it was occurring due to some whitespaces or extra lines. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this entry to the sklearn.metrics on line 410 in the same file to avoid redefining the sklearn.metrics section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I didn't noticed this previously!

I had moved to 410.


Code and Documentation Contributors
-----------------------------------
Expand Down
9 changes: 8 additions & 1 deletion sklearn/metrics/_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Konstantin Shmelkov <konstantin.shmelkov@polytechnique.edu>
# Christian Lorentzen <lorentzen.ch@googlemail.com>
# Ashutosh Hathidara <ashutoshhathidara98@gmail.com>
# Uttam kumar <bajiraouttamsinha@gmail.com>
# License: BSD 3 clause

import numpy as np
Expand Down Expand Up @@ -437,7 +438,7 @@ def mean_squared_error(


def mean_squared_log_error(
y_true, y_pred, *, sample_weight=None, multioutput="uniform_average"
y_true, y_pred, *, sample_weight=None, multioutput="uniform_average", squared=True
):
"""Mean squared logarithmic error regression loss.

Expand Down Expand Up @@ -466,6 +467,9 @@ def mean_squared_log_error(

'uniform_average' :
Errors of all outputs are averaged with uniform weight.
squared : bool, default=True
If True returns MSLE (mean squared log error) value.
If False returns RMSLE (root mean squared log error) value.

Returns
-------
Expand All @@ -480,6 +484,8 @@ def mean_squared_log_error(
>>> y_pred = [2.5, 5, 4, 8]
>>> mean_squared_log_error(y_true, y_pred)
0.039...
>>> mean_squared_log_error(y_true, y_pred, squared=False)
0.199...
>>> y_true = [[0.5, 1], [1, 2], [7, 6]]
>>> y_pred = [[0.5, 2], [1, 2.5], [8, 8]]
>>> mean_squared_log_error(y_true, y_pred)
Expand All @@ -505,6 +511,7 @@ def mean_squared_log_error(
np.log1p(y_pred),
sample_weight=sample_weight,
multioutput=multioutput,
squared=squared,
)


Expand Down