Accuracy computation with variable classes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 726
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 5
Description
❓ Questions/Help/Support
I've been using the Accuracy class (in ignite.metrics) successfully so far in a multi-class setting to compute test set accuracy.
Recently, I've hit a new scenario/dataset where the test set has different number of classes for each example. You can think of this as a multiple-choice selection task, where each example has a different number of candidates.
Now in this scenario, when I used Accuracy, I got the below error:
ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: Input data number of classes has changed from 13 to 81.
I dived into the code and I see that the base class for Accuracy, i.e., _BaseClassification assumes that the number of classes/candidates is fixed across test set examples. And this is why I'm getting the above error at run-time.
However, for multi-class accuracy, as you can see in the update() method here, we are simply computing the number of correct predictions via argmax along dimension-1 and measuring matches against y.
This computation of correct should be accurate even if the number of candidates changes across two examples from the test set, right?
So in effect, the computed accuracy would be correct even in such a case because the underlying variables are computed correctly?
What do you think, @vfdev-5? Is it possible to have a version of Accuracy for multi-class where there is no expectation that the number of classes is the same across all examples in the test set?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ignite/metrics/accuracy.py, especially _BaseClassification and Accuracy.update(), and reproduce the failure using inputs whose candidate counts vary between examples. Done means Accuracy can compute argmax-based matches for variable candidate counts without raising the fixed-class-count exception, with the existing metric behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100