Added The BInary Expected_Calibration_Error (ECE) Metric #3132
Added The BInary Expected_Calibration_Error (ECE) Metric #3132Zekrom-7780 wants to merge 10 commits intopytorch:masterfrom
Conversation
Apply Sweep Rules to your PR?
|
vfdev-5
left a comment
There was a problem hiding this comment.
Thanks for the PR @Zekrom-7780 !
I left few comments but I haven't yet fully checked the code and correctness.
Do I have to add new tests, and documentation for the new metric? I don't know whether I had to add them or not.
Yes, we need to add new tests and provide a docstring and include the metric to the docs (i'll guide how to do that once we are at this point, nothing complicated).
Main question about tests will be what would be the reference for our implementation. For example, in most of the cases, we are using sklearn to compute expected value.
Will be doing the MultiClassECE in a new pull request, since it feels that it is the better thing to do.
Won't be possible to have a single class for binary and multi-class ECE ?
| @@ -0,0 +1,57 @@ | |||
| import torch | |||
There was a problem hiding this comment.
First, let's put it into ignite/metrics/ExpectedCalibrationError.py instead of ignite/contrib/metrics/ExpectedCalibrationError.py
| def update(self, output): | ||
| y_pred, y = output | ||
|
|
||
| assert y_pred.dim() == 2 and y_pred.shape[1] == 2, "This metric is for binary classification." |
There was a problem hiding this comment.
Let's use the following way to raise errors instead of assert:
if not (y_pred.dim() == 2 and y_pred.shape[1] == 2):
raise ValueError("This metric is for binary classification")To assert if the input is binary we were doing previously something like here:
ignite/ignite/metrics/accuracy.py
Lines 51 to 67 in 4dc4e04
| self.corrects = torch.tensor([], device=self.device) | ||
|
|
||
| def update(self, output): | ||
| y_pred, y = output |
There was a problem hiding this comment.
We usually call .detach on both to stop grad computation like here:
ignite/ignite/metrics/accuracy.py
Line 231 in 4dc4e04
|
@vfdev-5 made the changes, Ready for comments
Will do it in the next commits if you want, actually I just wanted to understand how does the |
|
@Zekrom-7780 any updates on this PR ? |
|
@vfdev-5 I'll create the Then i'll move to writing the unit-tests, where I'll need your help, since I haven't written any as such |
…gnite into Issue_1009 The merge is necessary since I diverged from the main branch
|
@vfdev-5 , made the changes |
Fixes #1009
Description:
Added the binary
ECE(Expected_Calibration_Error)metric.Reviewers
cc. @vfdev-5
P.S.
MultiClassECEin a new pull request, since it feels that it is the better thing to do.