10000 [MRG+2] median_absolute_error multioutput by agamemnonc · Pull Request #14732 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged

Conversation

agamemnonc
Copy link
Contributor

Reference Issues/PRs

Closes #14728.

What does this implement/fix? Explain your changes.

Implements multioutput for median_absolute_error.

Any other comments?

Shall we also include support for sample_weight in this PR? See also #6217.

@agamemnonc
Copy link
Contributor Author

Not sure why Azure pipeline tests fail

@glemaitre
Copy link
Member

Regarding the failure, you need to add median_absolute_error in MULTIOUTPUT_METRICS in metrics/tests/test_common.py. Otherwise, we check that an error should be raised.

@agamemnonc
Copy link
Contributor Author

Thanks @glemaitre .

Any thoughts regarding sample_weight ? Should we implement this in this PR or a perhaps a different one?

@agamemnonc agamemnonc changed the title median_absolute_error multioutput [WIP] median_absolute_error multioutput Aug 23, 2019
@glemaitre
Copy link
Member

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 y and take the 50% value of the cumulative sum of the weights or something like that.

@agamemnonc agamemnonc changed the title [WIP] median_absolute_error multioutput [MRG] median_absolute_error multioutput Aug 23, 2019
@glemaitre glemaitre changed the title [MRG] median_absolute_error multioutput [MRG+1] median_absolute_error multioutput Sep 9, 2019
@agamemnonc
Copy link
Contributor Author

Conflicts with master resolved.

Any willing reviewers? :)

@glemaitre
Copy link
Member

ping @rth @jeremiedbb

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)
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted.

Fixed.

@agamemnonc agamemnonc changed the title [MRG+1] median_absolute_error multioutput [MRG+2] median_absolute_error multioutput Oct 21, 2019
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)
Copy link
Member

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.)

Copy link
Contributor Author

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.

Copy link
Member
@qinhanmin2014 qinhanmin2014 left a 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.

@glemaitre glemaitre merged commit d026e32 into scikit-learn:master Oct 22, 2019
@glemaitre
Copy link
Member

Let's merge then.

Thanks @agamemnonc!!!

@agamemnonc agamemnonc deleted the median_absolute_error_multioutput branch October 22, 2019 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

median_absolute_error multioutput
3 participants
0