Repository navigation
Conversation
With calculate_average: False, f1-score still dropped the last element of the precision/recall results as if it were the average, so the last class was missing from the output. multi_accuracy ignored the option and always appended the average, which did not match its meta names.
|
Can one of the admins verify this patch? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The
multi_accuracyandf1-scoremetrics inmultilabel_recognition.pymishandlecalculate_average: False.f1-scorebuilds its per-class values fromMultiLabelPrecisionandMultiLabelRecall, which receive the same config. Whencalculate_averageisFalse, those two return only the per-class values.F1Score.evaluatestill doesprecisions[:-1]/recalls[:-1], so the last class is silently dropped. With 3 labels, the metric returns 2 values whilemeta['names']lists 3.multi_accuracyignores the option and always appends the average.meta['names']has noaverageentry in that case, so the values and names don't match.The fix slices the precision/recall results to the number of labels in
f1-score, and returns only the per-class values frommulti_accuracywhen the average is disabled. This is howmulti_precisionandmulti_recallalready behave.Tests
New
tests/test_multilabel_metrics.pycovers both metrics with and without the average, on a 3-label example with hand-computed values. On master, the twocalculate_average: Falsetests fail:f1-scorereturns[1.0, 0.667]andmulti_accuracyreturns[1.0, 0.5, 0.5, 0.667]. With this change all 4 pass. The changed module adds no new pylint findings (.pylintrc, max line 120).