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

[MRG+2] median_absolute_error multioutput #14732

Merged

Conversation

@agamemnonc
Copy link
Contributor

agamemnonc commented Aug 22, 2019

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

This comment has been minimized.

Copy link
Contributor Author

agamemnonc commented Aug 23, 2019

Not sure why Azure pipeline tests fail

sklearn/metrics/regression.py Outdated Show resolved Hide resolved
sklearn/metrics/regression.py Outdated Show resolved Hide resolved
sklearn/metrics/regression.py Outdated Show resolved Hide resolved
@glemaitre

This comment has been minimized.

Copy link
Contributor

glemaitre commented Aug 23, 2019

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

This comment has been minimized.

Copy link
Contributor Author

agamemnonc commented Aug 23, 2019

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

This comment has been minimized.

Copy link
Contributor

glemaitre commented Aug 23, 2019

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 added 2 commits Oct 14, 2019
@agamemnonc

This comment has been minimized.

Copy link
Contributor Author

agamemnonc commented Oct 14, 2019

Conflicts with master resolved.

Any willing reviewers? :)

@glemaitre

This comment has been minimized.

Copy link
Contributor

glemaitre commented 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, None)

This comment has been minimized.

Copy link
@qinhanmin2014

qinhanmin2014 Oct 21, 2019

Member

We need to pass multioutput
this should be y_type, y_true, y_pred, multioutput = _check_reg_targets(y_true, y_pred, multioutput)

This comment has been minimized.

Copy link
@agamemnonc

agamemnonc Oct 21, 2019

Author Contributor

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)

This comment has been minimized.

Copy link
@qinhanmin2014

qinhanmin2014 Oct 22, 2019

Member

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

This comment has been minimized.

Copy link
@agamemnonc

agamemnonc Oct 22, 2019

Author Contributor

Good point, thanks. Now fixed.

Copy link
Member

qinhanmin2014 left a comment

will merge when green.

@glemaitre glemaitre merged commit d026e32 into scikit-learn:master Oct 22, 2019
19 checks passed
19 checks passed
LGTM analysis: C/C++ No code changes detected
Details
LGTM analysis: JavaScript No code changes detected
Details
LGTM analysis: Python No new or fixed alerts
Details
ci/circleci: deploy Your tests passed on CircleCI!
Details
ci/circleci: doc Your tests passed on CircleCI!
Details
ci/circleci: doc artifact Link to 0/doc/_changed.html
Details
ci/circleci: doc-min-dependencies Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 97.21%)
Details
codecov/project 97.21% (+<.01%) compared to ad0e9a9
Details
scikit-learn.scikit-learn Build #20191022.17 succeeded
Details
scikit-learn.scikit-learn (Linux py35_conda_openblas) Linux py35_conda_openblas succeeded
Details
scikit-learn.scikit-learn (Linux py35_ubuntu_atlas) Linux py35_ubuntu_atlas succeeded
Details
scikit-learn.scikit-learn (Linux pylatest_conda_mkl) Linux pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas) Linux pylatest_pip_openblas_pandas succeeded
Details
scikit-learn.scikit-learn (Linux32 py35_ubuntu_atlas_32bit) Linux32 py35_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py35_pip_openblas_32bit) Windows py35_pip_openblas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py37_conda_mkl) Windows py37_conda_mkl succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl) macOS pylatest_conda_mkl succeeded
Details
@glemaitre

This comment has been minimized.

Copy link
Contributor

glemaitre commented Oct 22, 2019

Let's merge then.

Thanks @agamemnonc!!!

@agamemnonc agamemnonc deleted the agamemnonc:median_absolute_error_multioutput branch Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.