Typed dataset statistics and per-class heatmaps - #472
Conversation
Give the health statistics real types (TypedDicts and aliases instead of `Any`), add `get_class_heatmaps` / `get_heatmap_statistics`, and let `get_statistics(per_class_heatmaps=True)` return the per-class grids via overloads. `missing_annotations` and `duplicates` now report the offending entries rather than a bare count. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The `build_health_grid` tests exercise the vizlab-backed renderer, which lives with that feature; this file keeps the data-level statistics tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`get_class_distributions` now returns `list[ClassDistributionRow]`, which is not assignable to the plot helper's `list[dict[str, Any]]` because `list` is invariant. Take the rows themselves, via the covariant `Sequence`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #472 +/- ##
==========================================
+ Coverage 93.97% 94.59% +0.61%
==========================================
Files 164 165 +1
Lines 12794 13446 +652
==========================================
+ Hits 12023 12719 +696
+ Misses 771 727 -44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
klemen1999
left a comment
There was a problem hiding this comment.
Some smaller suggestions but overall LGTM
| sample_size: int | None = None, | ||
| view: str | None = None, | ||
| *, | ||
| per_class_heatmaps: bool = False, |
There was a problem hiding this comment.
Let's expose this new flag on the CLI luxonis_ml data health as well
| class ClassDistributionRow(TypedDict): | ||
| """One class-count row in a dataset health distribution.""" | ||
|
|
||
| class_name: str |
There was a problem hiding this comment.
Technically class_name can be None as well by DatasetRecord definition. This maybe has also an effect on some of the plotting?
| str, dict[str, list[ClassDistributionRow]] | ||
| ] | ||
| Heatmaps: TypeAlias = dict[str, dict[str, list[list[int]]]] | ||
| ClassHeatmaps: TypeAlias = dict[str, dict[str, dict[str, list[list[int]]]]] |
There was a problem hiding this comment.
Since class can also be "none" we can maybe have separate heatmap for this case (ie. heatmap of annotations that don't have class specified).
Purpose
get_statisticsreturned loosely-typed nested dictionaries, which made the health output hard to consume and easy to get wrong. It also reportedmissing_annotationsand duplicates as bare counts, so you learned that something was wrong but not what.Split out of the
feat/vizlabbranch, which had grown to 81 commits; this is one of eight self-contained pieces that do not belong to vizlab itself.Specification
TypedDicts and aliases (DatasetStatistics,ClassDistributionRow,HeatmapRow, …) replacingAny.get_class_heatmapsandget_heatmap_statistics, plus aget_statistics(per_class_heatmaps=True)overload returning the per-class grids.missing_annotationsandduplicatesnow report the offending entries rather than a count.Dependencies & Potential Impact
The
missing_annotationsandduplicatesfields change shape (count → list of entries), so anything reading those values directly needs updating. Everything else is additive.Deployment Plan
None / not applicable
Testing & Validation
tests/test_data/test_health.py— statistics, per-class heatmaps, and shared-sample handling.ruffandpyrightclean.AI Usage
Assisted-by: Claude:claude-fable-5