Skip to content

Heatmap Visualization

Fetch and render evaluation results (the distribution of internal features and errors) as a 2-axis heatmap to see where the model errs.

  • The Heatmap returned by Result.get_heatmap(...) can be rendered/saved repeatedly with .show() / .to_figure() / .save().
  • Subtracting two heatmaps (hm_a - hm_b) visualizes distribution shift (HeatmapDelta).

Which axes should I look at?

You can also use the Heatmap Advisor (result.recommend_heatmaps()), which recommends "which axis pairs reveal where errors concentrate".

Fetch and render

result = evaluator.request_evaluation(method_name="...")

# 1) Fetch the heatmap
hm = result.get_heatmap(
    dataset_type="pool",       # data source (see table below)
    x_axis="pred_score",       # None = task default
    y_axis="error_proba",      # None = task default
    target="error_proba",      # column used for coloring
    n_bins=20,                 # bins per axis (1–100)
    aggregation_level="input_id",  # "bbox" / "input_id" / "sequence"
)

# 2) Render
hm.show(mode="error_ratio")    # display on screen
fig = hm.to_figure()           # get a Figure (for saving / embedding)
hm.save("heatmap.png")         # save to file

Main get_heatmap parameters

Argument Default Description
dataset_type None (every dataset) Data source. Both log-based (pool / deploying) and evaluation (train / val) are supported (the server selects). When unset, every dataset the result holds is fetched in one call and returned as a HeatmapGroup.
x_axis / y_axis None (task default) Column keys for the axes (e.g. pred_score / error_proba).
target None (task default) Column used for error coloring.
n_bins 20 Bins per axis (1–100).
aggregation_level "input_id" "bbox" / "input_id" / "sequence".
bbox_strategy None (OD) bbox aggregation/filter config (same shape as BBoxStrategy).
property_filters None Discrete filters keyed by column name (e.g. {"pred_class_id": [0, 1]}). Must not include dataset_type.

Pass dataset_type as the dedicated argument

Putting "dataset_type" inside property_filters raises a ValueError. Always use the dataset_type= argument.

Fetching every dataset at once (HeatmapGroup)

Calling get_heatmap() without a dataset_type fetches the heatmaps of every dataset the result holds, in a single server call.

group = result.get_heatmap()          # dataset_type omitted = every dataset
group.show_all()                      # draw them side by side
group["val"].show()                   # pick one out
for dataset_type, hm in group:        # iterate
    hm.save(f"heatmap_{dataset_type}.png")

hm = result.get_heatmap(dataset_type="pool")   # fetch a single dataset

ALRecommendation.get_heatmap(), ResultSeries.heatmaps(), and the Heatmap Advisor's get_heatmap() cover every dataset the same way when dataset_type is unset.

Rendering options (Heatmap.show / to_figure / save)

Argument Default Description
mode "count" What to color by. "count" (density) / "error_ratio" (error rate).
cmap None matplotlib colormap name. None auto-picks by mode (count=Greens / error_ratio=Reds).
color_scale "auto" "auto" (0..max) / "unit" (0..1).
figsize (8, 8) (width, height) in inches.

Delta (distribution shift)

Subtracting two heatmaps yields a HeatmapDelta. You can visualize distribution shift — train vs. val, before vs. after collection, etc. The two must share x/y labels, axis ranges, n_bins, and aggregation_level.

delta = result.get_heatmap(dataset_type="train") - result.get_heatmap(dataset_type="val")
delta.show(field="delta_error_ratio")

Delta display fields (field)

field Meaning
delta_count Difference in counts (a − b, default)
delta_count_ratio Difference in count ratio
delta_error_ratio Difference in error rate
a_count / b_count Per-heatmap counts (e.g. for detecting OOD bins)

The default colormap is the diverging RdBu_r (positive = bins where a > b read warm). Because a_count / b_count are preserved, you can also extract bins that exist in a but not b (out-of-distribution):

ood_bins = [b for b in delta.bins if b.a_count > 0 and b.b_count == 0]

When a delta is valid

A delta is valid only when the axis ranges match between the two heatmaps (e.g. [0,1]-bounded axes like error_proba / pred_score). With mismatched dynamic-range axes it raises a ValueError.

Heatmaps over time (multiple epochs)

To inspect heatmaps across epochs side by side, ResultSeries.heatmaps(...) returns a filmstrip (HeatmapSeries). See Result Time-Series & Version Comparison for details.

series = evaluator.get_result_series()
hs = series.heatmaps(x_axis="pred_score", y_axis="error_proba", dataset_type="pool", epochs=[1, 5, 10])
hs.show()                                  # display each epoch side by side
hs.show_deltas(field="delta_error_ratio")  # consecutive-epoch deltas