-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG+2] median_absolute_error multioutput #14732
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
[MRG+2] median_absolute_error multioutput #14732
Conversation
Not sure why Azure pipeline tests fail |
Regarding the failure, you need to add |
Thanks @glemaitre . Any thoughts regarding |
I would say to implement it in another PR. I am also not sure how to apply some weight during the computation of the median such that it is meaningful. You would need to sort |
Conflicts with master resolved. Any willing reviewers? :) |
ping @rth @jeremiedbb |
sklearn/metrics/regression.py
Outdated
if y_type == 'continuous-multioutput': | ||
raise ValueError("Multioutput not supported in median_absolute_error") | ||
return np.median(np.abs(y_pred - y_true)) | ||
_, y_true, y_pred, _ = _check_reg_targets(y_true, y_pred, None) |
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.
We need to pass multioutput
this should be y_type, y_true, y_pred, multioutput = _check_reg_targets(y_true, y_pred, multioutput)
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.
Well spotted.
Fixed.
sklearn/metrics/regression.py
Outdated
if y_type == 'continuous-multioutput': | ||
raise ValueError("Multioutput not supported in median_absolute_error") | ||
return np.median(np.abs(y_pred - y_true)) | ||
_, y_true, y_pred, _ = _check_reg_targets(y_true, y_pred, multioutput) |
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.
Let's use y_type, y_true, y_pred, multioutput = _check_reg_targets(y_true, y_pred, multioutput)
here. This will be more consistent. (Actually since we call check_array in _check_reg_targets, multioutput will sometimes be modified.)
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.
Good point, thanks. Now fixed.
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.
will merge when green.
Let's merge then. Thanks @agamemnonc!!! |
Reference Issues/PRs
Closes #14728.
What does this implement/fix? Explain your changes.
Implements
multioutput
formedian_absolute_error
.Any other comments?
Shall we also include support for
sample_weight
in this PR? See also #6217.