Skip to content

Typed dataset statistics and per-class heatmaps - #472

Draft
kozlov721 wants to merge 3 commits into
mainfrom
feat/dataset-health-stats
Draft

Typed dataset statistics and per-class heatmaps#472
kozlov721 wants to merge 3 commits into
mainfrom
feat/dataset-health-stats

Conversation

@kozlov721

Copy link
Copy Markdown
Collaborator

Purpose

get_statistics returned loosely-typed nested dictionaries, which made the health output hard to consume and easy to get wrong. It also reported missing_annotations and duplicates as bare counts, so you learned that something was wrong but not what.

Split out of the feat/vizlab branch, which had grown to 81 commits; this is one of eight self-contained pieces that do not belong to vizlab itself.

Specification

  • Real types for the statistics: TypedDicts and aliases (DatasetStatistics, ClassDistributionRow, HeatmapRow, …) replacing Any.
  • New get_class_heatmaps and get_heatmap_statistics, plus a get_statistics(per_class_heatmaps=True) overload returning the per-class grids.
  • missing_annotations and duplicates now report the offending entries rather than a count.

Dependencies & Potential Impact

The missing_annotations and duplicates fields 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. ruff and pyright clean.

AI Usage

Assisted-by: Claude:claude-fable-5

kozlov721 and others added 2 commits August 1, 2026 21:08
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>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d18808df-09fc-4d11-9224-66dac1d9dc3b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 1, 2026
`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

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.05495% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.59%. Comparing base (f45cf41) to head (651b08a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
luxonis_ml/data/utils/data_utils.py 94.92% 7 Missing ⚠️
luxonis_ml/data/datasets/luxonis_dataset.py 75.00% 2 Missing ⚠️
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     
Flag Coverage Δ
pytest-ubuntu-latest 94.59% <95.05%> (+0.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@klemen1999 klemen1999 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some smaller suggestions but overall LGTM

sample_size: int | None = None,
view: str | None = None,
*,
per_class_heatmaps: bool = False,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]]]]]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants