Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array #23548

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
merged 8 commits into from
Jun 21, 2022

Conversation

haochunchang
Copy link
Contributor

Reference Issues/PRs

Fixes #23368

What does this implement/fix? Explain your changes.

  • Change the 2 calls check_array(., ensure_2d=False) at the beginning of coverage_error to ensure_2d=True.
  • Add "if metric == coverage_error then reshape y_true to 2d" in test_regression_thresholded_inf_nan_input in metrics common test to fix failed tests.
  • Add coverage_error specific test to check correct error message is raised when passing a 1d array as input.

Any other comments?

Not sure if adding the "if else" in the common test is elegant. It might adds more cognitive complexity. Hoping for any comment on it.

@haochunchang haochunchang changed the title [WIP] Ensure correct sklearn.metrics.coverage_error error message for 1D array [WIP] FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array Jun 6, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

@haochunchang haochunchang changed the title [WIP] FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array [MRG] FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array Jun 6, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Please add an entry to the change log at doc/whats_new/v1.2.rst with tag |Fix|. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan added the Quick Review For PRs that are quick to review label Jun 7, 2022
@thomasjpfan thomasjpfan changed the title [MRG] FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array FIX Ensure correct sklearn.metrics.coverage_error error message for 1D array Jun 7, 2022
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you, @haochunchang.

@jjerphan jjerphan merged commit e98e035 into scikit-learn:main Jun 21, 2022
ogrisel pushed a commit to ogrisel/scikit-learn that referenced this pull request Jul 11, 2022
…D array (scikit-learn#23548)

* Change input array to ensure_2d=True

* Reshape input list to 2D if metric is coverage_error

* Add test for error message with 1D array on coverage_error

* Modify 1D error message test

* Use parametrize to test different 1d arrays

* Explain why reshape in test_regression_thresholded_inf_nan_input

* Add changelog entry for this fix

* Add test comments to sklearn/metrics/tests/test_ranking.py

Co-authored-by: Julien Jerphanion <[email protected]>

Co-authored-by: Julien Jerphanion <[email protected]>
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Aug 4, 2022
…D array (scikit-learn#23548)

* Change input array to ensure_2d=True

* Reshape input list to 2D if metric is coverage_error

* Add test for error message with 1D array on coverage_error

* Modify 1D error message test

* Use parametrize to test different 1d arrays

* Explain why reshape in test_regression_thresholded_inf_nan_input

* Add changelog entry for this fix

* Add test comments to sklearn/metrics/tests/test_ranking.py

Co-authored-by: Julien Jerphanion <[email protected]>

Co-authored-by: Julien Jerphanion <[email protected]>
glemaitre pushed a commit that referenced this pull request Aug 5, 2022
…D array (#23548)

* Change input array to ensure_2d=True

* Reshape input list to 2D if metric is coverage_error

* Add test for error message with 1D array on coverage_error

* Modify 1D error message test

* Use parametrize to test different 1d arrays

* Explain why reshape in test_regression_thresholded_inf_nan_input

* Add changelog entry for this fix

* Add test comments to sklearn/metrics/tests/test_ranking.py

Co-authored-by: Julien Jerphanion <[email protected]>

Co-authored-by: Julien Jerphanion <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:metrics Quick Review For PRs that are quick to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sklearn.metrics.coverage_error wrong error message for 1D array
3 participants