-
Notifications
You must be signed in to change notification settings - Fork 462
Add unified Hierarchical MetricCollection (torchmetrics) + unit tests #4689
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
Conversation
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.
Thanks @Jyc323 for extending OTX h-cls metrics collection!
Considering #4706, it makes sense to create a chapter for h-cls in https://open-edge-platform.github.io/training_extensions/latest/guide/tutorials/advanced/index.html
As in the loss PR, there should be a way how OTX users can quickly utilize new metrics by modifying model recipe. Also, it might be an idea to extend OTX default h-cls metrics collection to make the default metrics more expressive right out of the box
Hi @sovrasov, thanks for the review and comments. Per your feedback, I removed the As an extension, I integrated the current hierarchical accuracy calculation into |
Thanks for the update! I see there is a way how users can utilize the new metrics, but it's hard hard to find it without a careful review of OTX source code. That I'm suggesting here is to add a tutorial on how to use the new h-cls features via both OTX recipe and API. You can check other tutorials for instance, |
@kprokofi will temporally cover me, as I'm off next week |
@kprokofi I added the documentation under |
library/docs/source/guide/tutorials/advanced/hier_metric_collection.rst
Outdated
Show resolved
Hide resolved
Hi @sovrasov , thanks for the reviewing. I've reviewed the errors from the Unit-Test-with-Python3.12 run, but they don't appear to be caused by my changes. Could you please advise on what I should do?
As for 'Required Check lib-lint-and-test', I don't think the log provide enough information, could you please tell me where I can find detailed information?
Thanks for your help |
Indeed, that can be unrelated CI errors already fixed in develop. Could you merge changes from develop and resolve conflicts first? Then, we can run the CI one more time ![]() |
Hi @sovrasov, I already merged and resolved the conflicting, please let me know if there are any issues. Thanks a lot |
Unfortunately, CI is still not in the best shape, ETA for a fix is next week |
Hi @sovrasov, I think your latest review comment makes sense. I already fixed it and pushed the modification. Please let me know anything else I need to do from my side. Have a great day! |
Summary
This PR introduces a hierarchical metrics module and a consistent entrypoint for training/eval. It includes leaf accuracy, full-path accuracy, prediction path-consistency ratios, and label-count–weighted precision into a single MetricCollection that plugs into existing OTX/torchmetrics flows.
LeafAccuracy
Macro-averaged correctness at the leaf level (final decision); mitigates class-imbalance bias.
FullPathAccuracy
Strict correctness across all levels; prevents inflated scores from partial matches.
InconsistentPathRatio (predictions)
Detects taxonomy-violating predictions (child not under parent); highlights model–hierarchy mismatches.
WeightedHierarchicalPrecision
Per-level macro precision aggregated with label-count weights; balances coarse vs. fine levels and stays robust to imbalance.
How to test
Checklist
License
Feel free to contact the maintainers if that's a concern.