Skip to content

fix(eval): reject table columns that have no computed value - #660

Open
BarsamErshadi wants to merge 3 commits into
roboflow:developfrom
BarsamErshadi:fix/table-unknown-columns
Open

BarsamErshadi wants to merge 3 commits into
roboflow:developfrom
BarsamErshadi:fix/table-unknown-columns

Conversation

@BarsamErshadi

@BarsamErshadi BarsamErshadi commented Nov 4, 2026 •

Copy link
Copy Markdown

What does this PR do?

SequenceResult.table(columns=...), BenchmarkResult.table(columns=...) and trackers eval --columns printed a score of zero for any column that had no computed value. That covers a metric family that was not requested as well as a misspelled name.

--metrics defaults to CLEAR only, so --columns '[MOTA,HOTA,IDF1]' without --metrics is an easy command to run. It showed HOTA and IDF1 as 0.000 and exited 0, even though neither was computed. The cause is the final return 0 in _get_metrics_dict. I replaced it with a ValueError that names the column.

Related Issue(s): None. I found no open issue or PR for this. Open PR #556 touches the table helpers in the same file, but not these lines (see Additional Context).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

It does change behaviour for anyone relying on the zero fill (see Additional Context).

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:

I added TestTableColumns to tests/eval/test_evaluate.py. It covers:

  • a column from a family that was not computed, and an unknown name, on the sequence table
  • the same check on the benchmark table
  • real values still rendering when the families are computed
  • eval_command in single-sequence and benchmark mode: it returns 1, prints Error: ..., prints no table and writes no --output file

On unfixed code, 7 of the 8 tests failed, with DID NOT RAISE ValueError for the table tests and assert 0 == 1 for the CLI tests. The 8th test guards existing behaviour and passed both before and after. With the fix, all 8 pass.

Minimal repro (g.txt and t.txt are the same two-row file, 1,1,0,0,10,10,1,1,1 and 2,1,0,0,10,10,1,1,1):

Before:

$ trackers eval --gt g.txt --predictions t.txt --columns=[MOTA,HOTA,IDF1] --output out.json
Sequence                         MOTA   HOTA   IDF1
---------------------------------------------------
g                             100.000  0.000  0.000

Results saved to: out.json
rc=0 out.json exists: yes
$ trackers eval --gt g.txt --predictions t.txt --columns=[MOTa,IDSw] --output out.json
Sequence                      MOTa  IDSw
----------------------------------------
g                                0     0

Results saved to: out.json
rc=0 out.json exists: yes

After:

$ trackers eval --gt g.txt --predictions t.txt --columns=[MOTA,HOTA,IDF1] --output out.json
Error: Column 'HOTA' has no computed value: check the name, or add its metric family to metrics.
rc=1 out.json exists: no
$ trackers eval --gt g.txt --predictions t.txt --columns=[MOTa,IDSw] --output out.json
Error: Column 'MOTa' has no computed value: check the name, or add its metric family to metrics.
rc=1 out.json exists: no

Requesting the families gives the same output before and after:

$ trackers eval --gt g.txt --predictions t.txt --metrics=[CLEAR,HOTA,Identity] --columns=[MOTA,HOTA,IDF1] --output out.json
Sequence                         MOTA     HOTA     IDF1
-------------------------------------------------------
g                             100.000  100.000  100.000

Results saved to: out.json
rc=0 out.json exists: yes

I ran these through python -m trackers.cli, not the installed trackers script. The rc= lines come from my shell loop.

Results:

  • Full suite with the fix, run with -W ignore, so it does not show warnings: 2 failed, 2092 passed, 5 skipped. Neither failure comes from this change:
    • test_real_reid_model_runs_over_frames fails with ModuleNotFoundError: No module named 'reid', and fails the same way without my change. That package is missing from my environment.
    • test_tracker_regression[dancetrack-dancetrack_flat_data-bytetrack] failed once with Invalid MOT format while reading a file from the shared test cache in ~/.cache/trackers-test, then passed on rerun both with and without my change. Other test runs were active on this machine at the time, so I suspect a concurrent write to the cache, but I did not confirm that.
  • Hooks on the changed files: 12 passed, 6 skipped because they had no matching files, 0 failed. I used pre-commit run --files on the changed files, not --all-files.
  • I also called the default table() (no columns) for all 7 combinations of metric families. This covered sequence and benchmark results, and results reloaded from JSON. None of them raised. This was a one-off script and is not in the test suite.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

The documentation change is a Raises: entry on the two table() methods and on _get_metrics_dict. The doc pages did not need changing: every --columns example in README.md and docs/ already passes the matching --metrics.

Additional Context

Some behaviour changes and trade-offs for you to judge:

  • Scripts that relied on the zero fill now fail. A table(columns=...) call or trackers eval --columns command with a column that has no value used to succeed. It now raises, or exits 1 on the CLI.
  • --output is no longer written when --columns is bad. eval_command calls table() before saving, so the error happens first. Before this change, the JSON was saved. The evaluation has already run by then, so a typo in --columns on a long benchmark throws away that work, and the error only appears at the end. I did not measure the cost on a real benchmark. I kept this PR small and did not move the save or check the columns up front. Either would be a reasonable follow-up if you prefer it.
  • The error reports only the first bad column. --columns=[MOTa,IDSw] names MOTa only, so a user with two bad columns finds the second on the next run.
  • Overlap with feat(multicamera): add world-plane HOTA #556. That PR rewrites _format_sequence_table and _format_benchmark_table in results.py, but it keeps calling _get_metrics_dict and does not change its return 0. It may still need a rebase because the changes are close together. I read its diff but did not test the two together.

_get_metrics_dict returned 0 for any column it could not find in a
computed metric family, and _format_value rendered that as a score.
`trackers eval --columns '[MOTA,HOTA,IDF1]'` without --metrics computes
only CLEAR, so it printed HOTA and IDF1 as 0.000 and exited 0, and a typo
such as MOTa printed 0. Neither could be told apart from a real zero.

Raise ValueError naming the column instead. eval_command already catches
ValueError around table(), so the CLI prints the error and returns 1. It
calls table() before saving, so --output is not written on that error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Borda
Borda requested a balanced review from Copilot November 4, 2026 19:49
@Borda Borda added the bug Something isn't working label Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change to reject unavailable evaluation columns instead of displaying misleading zero scores.

No open issues 🎉

What changed in this PR

This PR prevents evaluation tables from presenting uncomputed metrics or misspelled column names as zero scores.

Changes:

  • Raise ValueError naming the unavailable column and document the exception.
  • Add regression tests for table validation, valid metric rendering, and CLI failures without JSON output.
  • Document the behavior change and migration guidance in the changelog.
File Description
tests/​eval/​test_evaluate.py Tests invalid columns, computed values, and CLI error handling.
src/​trackers/​eval/​results.py Replaces zero fallback with an explicit error and documents it.
CHANGELOG.md Explains the change and how affected commands should be updated.

Review effort: Balanced

@AlexBodner

Copy link
Copy Markdown
Collaborator

Hello, thank you for the contribution and the detailed repro!
The silent 0 should definitely go.

The trade-offs you list in Additional Context are what I'd like to avoid though, with the error, one wrong column makes the whole command fail, the --output file isn't written even though the evaluation finished, and only the first bad column gets reported. Could table() check the requested columns against the computed ones first, skip the ones it can't show with a warning that names all of them, and print the rest? Something like:

skipped = [col for col in columns if col not in available]
if skipped:
    warnings.warn(f"Skipping columns with no computed value: {', '.join(skipped)}. ...", UserWarning, stacklevel=3)
columns = [col for col in columns if col in available] or available

where available is what _get_available_columns already returns for the computed metrics. If none of the columns are valid, it can fall back to same as not passing --columns.

What are your thoughts?

For the tests, a single parametrized test is enough, with two cases: columns=["MOTA", "HOTA"] when only CLEAR was computed HOTA is not present, so should be skipped from the table.
The other has columns=["MOTA", "IDSw"] and would skip IDSw because of the typo. In both, check that the warning names the bad column and that the table still shows MOTA.

We should also define the behaviour when all are skipped. We can either fallback to the default table, like no parameters were passed or return an empty table, which is impractical, but shows your error more clearly. For this, A second small test can check that columns=["IDSw"] alone follows the behaviour we decide.
Would like to hear your thoughts here!

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants