Repository navigation
Preserve classification probabilities when computing accuracy metrics - #2783
Open
林SO (Linxiushen) wants to merge 1 commit into
Open
林SO (Linxiushen) wants to merge 1 commit into
林SO (Linxiushen) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the changes preserving floating-point classification scores while retaining integer conversion for hard labels.
No open issues 🎉
What changed in this PR
This PR fixes Olive’s classification metric evaluation by preserving floating-point probabilities and logits until Torchmetrics applies thresholding or argmax, while retaining integer conversion for hard labels.
Changes:
- Share prediction preparation across accuracy, F1, precision, and recall.
- Add scoring regressions covering input formats, classification tasks, thresholds, averaging, and AUROC/perplexity controls.
- Update mocked tests to expect prediction dtype preservation.
| File | Description |
|---|---|
test/evaluator/test_classification_probabilities.py |
Adds real scoring regressions for floating predictions and hard-label compatibility. |
test/evaluator/test_accuracy.py |
Updates prediction tensor-conversion expectations. |
olive/evaluator/accuracy.py |
Preserves floating classification scores while converting hard labels to integers. |
Review effort: Balanced
This branch has not been deployed
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.
Describe your changes
Classification metrics currently cast predictions to integers before Torchmetrics applies its threshold or argmax. For example, binary scores
[0.9, 0.8, 0.1, 0.2]with targets[1, 1, 0, 0]report accuracy0.5and F1/precision/recall0.0instead of1.0.Preserve floating scores in the four classification metrics while keeping integer conversion for hard labels, including multiclass class-label vectors. Add real scoring regressions for probabilities/logits, custom thresholds, multiclass/multilabel tasks, input representations, fractional scores and averaging, plus AUROC/perplexity controls.
Validation: all 41 new fixed-array CPU scoring regressions pass; the same file gives 18 failures and 23 passes on the untouched base. The combined neighboring tests give 76 passed, 1 failed. The failure is an existing
test_metrics_configtest requiring the unavailable optionalhuggingface/evaluatepackage; it also fails on a fresh archive of the untouched base. Tests used--noconftestto avoid repository-wide model-export fixtures; no model inference or GPU validation. Changed-filelintrunner -a, Ruff 0.15.11 check/format and Pylint 3.3.6 passed.AI assistance: implementation, regression design and automated review were assisted by OpenAI Codex.
Checklist before requesting a review
lintrunner -a(Optional) Issue link
No existing issue; reproduced directly on current main.