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

support multilabel confusion matrix #533

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

0ssamaak0
Copy link

using sklearn multilabel_confusion_matrix

sample usage:

confusion_metric  = evaluate.load("confusion_matrix", config_name="multilabel")


y_true= np.array([[0, 0, 0, 0, 1], [1, 0, 1, 0, 0], [0, 0, 1, 0, 1], [1, 0, 0, 0, 0]])
y_pred= np.array([[0, 1, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]])

confusion_metric.compute(references= y_true, predictions= y_pred)

output:

{'confusion_matrix': array([[[2, 0],
         [1, 1]],
 
        [[3, 1],
         [0, 0]],
 
        [[1, 1],
         [0, 2]],
 
        [[3, 1],
         [0, 0]],
 
        [[1, 1],
         [0, 2]]])}

@0ssamaak0
Copy link
Author

@lvwerra

Copy link
Member

@lvwerra lvwerra 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, added a few small comments!

metrics/confusion_matrix/README.md Show resolved Hide resolved
metrics/confusion_matrix/confusion_matrix.py Outdated Show resolved Hide resolved
metrics/confusion_matrix/README.md Outdated Show resolved Hide resolved
closing ticks for the code block
adding config_name to load
adding config_name="multilabel" to load
@0ssamaak0
Copy link
Author

There was a problem with file formatting, I reformatted it and comitted the new code

@0ssamaak0
Copy link
Author

There's an error in tests, I can't understand it, it seems to be unrelated with the code 😅 sorry for inconvenience

Copy link
Member

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but I wonder if it should be a separate metric to keep 1:1 mapping to sklearn

metrics/confusion_matrix/confusion_matrix.py Outdated Show resolved Hide resolved
fixing error in test

Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
@0ssamaak0
Copy link
Author

Overall LGTM, but I wonder if it should be a separate metric to keep 1:1 mapping to sklearn

I'm not sure 100% what is the optimal way, but I think the main idea behind evaluate is to be an abstraction.

anyway, if you think if it's better to be in a seperate module I can do it.

thank you ☺️

@0ssamaak0
Copy link
Author

@osanseviero will you accept the request? I've done the suggested edites

@0ssamaak0
Copy link
Author

thanks for rerunning the workflow, but I don't understand what's the problem 😬

adding `array()` in 2nd example
@0ssamaak0
Copy link
Author

I fixed the problem in docstring example that causes unit test failure, can you run the test and merge please? @lvwerra
thank you

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.

None yet

3 participants