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

DOC Updated documentation to show jaccard score usage for image comparison #21978

Merged
merged 2 commits into from Jan 21, 2022

Conversation

JakeCowton
Copy link
Contributor

What does this implement/fix? Explain your changes.

Fixes #21977

Any other comments?

I'm not sure what the use case is for having the docs show the way to calculate the Jaccard score for the first row of a matrix, but given how long those docs have been around I'm hesitant to assume they're wrong. Instead I've added lines to show how to calculate the Jaccard score for 2D input, often used for comparing binary images.

@JakeCowton JakeCowton marked this pull request as ready for review December 14, 2021 16:07
@cmarmo
Copy link
Member

cmarmo commented Dec 15, 2021

Thanks @JakeCowton for your pull request.
The test on the docstring you have modified is failing

=================================== FAILURES ===================================
___________ [doctest] sklearn.metrics._classification.jaccard_score ____________
[gw0] linux -- Python 3.7.11 /usr/share/miniconda/envs/testvenv/bin/python
765     ...                    [1, 0, 0]])
766 
767     In the binary case:
768 
769     >>> jaccard_score(y_true[0], y_pred[0])
770     0.6666...
771 
772     In the 2D comparison case (e.g. image similarity):
773 
774     >>> jaccard_score(y_true.flatten(), y_pred.flatten())
Expected:
    0.6666...
Got:
    0.6

Do you mind fixing it? Green checks will bring more attention to your work. Thanks.

Docs now show 2D jaccard score usage for image comparison
@JakeCowton
Copy link
Contributor Author

@cmarmo I've corrected the necessary components

Copy link
Member

@cmarmo cmarmo left a comment

Choose a reason for hiding this comment

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

I do not have any objection to this addition, but let's wait for a core-dev review.
Thanks for your contribution

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.

This looks sensible to me. Thank you, @JakeCowton!

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.

Thanks for the PR @JakeCowton !

sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
doc/modules/model_evaluation.rst Outdated Show resolved Hide resolved
@thomasjpfan thomasjpfan changed the title Updated documentation to show jaccard score usage for image comparison DOC Updated documentation to show jaccard score usage for image comparison Jan 21, 2022
@JakeCowton
Copy link
Contributor Author

@thomasjpfan thanks, I've integrated those changes.

@jjerphan jjerphan merged commit 08e0216 into scikit-learn:main Jan 21, 2022
mathijs02 pushed a commit to mathijs02/scikit-learn that referenced this pull request Dec 27, 2022
…rison (scikit-learn#21978)

* FIX Updated jaccard score documentation

Docs now show 2D jaccard score usage for image comparison

* Updated jaccard_score docs to use micro avg in 2d comparison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs for binary jaccard score only evaluate the first row of matrix
4 participants