-
-
Notifications
You must be signed in to change notification settings - Fork 695
remove sklearn dependency from cohenkappa score calculation logic and applied custom calculation and updated tests #3731
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
Open
avishkarsonni
wants to merge
9
commits into
pytorch:master
Choose a base branch
from
avishkarsonni:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9c1b2ab
remove sklearn dependency from cohenkappa score calculation logic and…
avishkarsonni d6782e7
updated the docstring with the correct changes
avishkarsonni c5eefb0
Merge branch 'pytorch:master' into master
avishkarsonni add7192
changed the implementation to ConfusionMatrix for calculation of Cohe…
avishkarsonni 8808d09
added the conversion of GPU tensors to CPU and then call the .double(…
avishkarsonni e80d750
Merge branch 'pytorch:master' into master
avishkarsonni 16bcc77
Changed the approach to the match the dtype of confision matrix to th…
avishkarsonni 39cc54b
update ConfusionMatrix import path in CohenKappa class docstring
avishkarsonni 358d4f2
update dtype handling in _cohen_kappa_score and reinstate input type …
avishkarsonni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we use ignite's confusion matrix class to compute this metric?
If we use
ConfusionMatrix, we should providenum_classesas input argument... In order to keep backward compatibility, we can add num_classes arg to the constructor as optional kwargs.We can have two private cohen kappa implementations: one using EpochMetric (current one) and second using ConfusionMatrix. The public CohenKappa can route depending on
num_classesarg.In the private implementation using EpochMetric we should still use ConfusionMatrix to compute the confusion matrix in
compute()method instead of doing that manually (as currently) to avoid bugs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used
bincountas I was aware of it and from start planned as such but now as mentioned it is possible. in the start of this PR it was not intuitive to me as it needsnum_classesat init. Currentimplinfers it dynamically from data, but it is indeed possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And again this method is better only when the user knows
num_classesif not we will need a fall back to infer it from the data on its own. Both of the methods have same time complexity, just advantage of usingConfusionMatrixis edge case coverage over current approach, would love to hear what would be a better approach!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benefit of using
ConfusionMatrixis that we do not store the list of y_preds and y_true in RAM vs the current implementation usingEpochMetric. Drawback of usingConfusionMatrixis that we should specifynum_classesin the metric constructor and also it gives a backward compatibility break.OK, the suggestion for this PR: let's use
ConfusionMatrixin the_cohen_kappa_scorein order to avoid using manual confusion matrix computation. We can instantiate an object of ConfusionMatrix with the number of classes and do a singleupdateand callcompute.