Skip to content

State what the bulk reduce step accepts: evaluator format is not bulk input, and confusion matrix plus field comparisons are required - #526

Open
YuuGR1337 wants to merge 3 commits into
awslabs:devfrom
YuuGR1337:fix/issue-481
Open

YuuGR1337 wants to merge 3 commits into
awslabs:devfrom
YuuGR1337:fix/issue-481

Conversation

@YuuGR1337

Copy link
Copy Markdown

Fixes #481


Closes awslabs#481

Signed-off-by: YuuGR1337 <yudhatamvan25@gmail.com>
@hayleypark

Copy link
Copy Markdown
Contributor

Thanks @YuuGR1337, taking this; full review after the release work. Heads-up from a first pass: #481 asks for specific fixes in Evaluation/README.md, bulk-evaluation.md and map-reduce-evaluation.md. This PR adds a README note instead, so it wouldn't close #481 as is. #481 also depends on #477, which is landing now.

@vawsgit vawsgit 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.

needs changes

Measured at head 52593cb, with stickler imported from that checkout's src.

1. The new note says default compare_with() output is accepted. It is rejected.

stickler/README.md

Lines 685 to 687 in 52593cb

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` accept default `compare_with()` outputs (confusion matrix plus field comparisons), not `evaluator_format=True` output. Evaluator-format input is silently accepted and yields all-zero metrics.

compare_with() keys: ['field_scores', 'overall_score']
update_from_comparison_result -> ValueError comparison_result missing 'confusion_matrix' key

Bulk input needs include_confusion_matrix=True. Confidence and bounding-box metrics also need document_field_comparisons=True (or add_confidence_metrics=True). Please name those flags. With include_confusion_matrix=True alone, confusion-matrix metrics work (cm_f1 0.667). So "plus field comparisons are required" overstates the case for those metrics.

2. "Evaluator-format input … yields all-zero metrics" is true only without the confusion-matrix flag. With evaluator_format=True, include_confusion_matrix=True, cm_f1 is 0.667 (correct). Only weighted_overall_score is silently 0.0 (the correct value is 0.5), because that output has overall and not overall_score. A user who sees non-zero metrics will think the warning does not apply.

3. Fixes #481 would close #481 with none of its edits made. The PR changes only README.md. The statements #481 lists are still in the published docs: docs/docs/Guides/Evaluation/README.md:335, docs/docs/Guides/Evaluation/bulk-evaluation.md:285, and docs/docs/Advanced/map-reduce-evaluation.md:7, 65, 94. hayleypark said the same in this thread. Either make those edits, or change the body to Refs #481 and drop Closes #481 from the commit body.

4. The PR title is not a Conventional Commits subject. A squash merge with this title gives the release notes a commit with no type. Retitle it to, for example, docs: state what the bulk reduce step accepts.

Verified and cleared: one commit, two README lines, no conflict with dev. No CHANGELOG entry is needed.

@sromoam sromoam 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.

Thanks for picking this up, YuuGR1337.

Must fix

I agree with vawsgit's review. Points 1 to 3 still apply at 52593cb. Measured against this branch:

  1. Default compare_with() output is rejected, not accepted. update_from_comparison_result() and aggregate_from_comparisons() both raise ValueError: comparison_result missing 'confusion_matrix' key (bulk_structured_model_evaluator.py:284). They need include_confusion_matrix=True, as their docstrings say.
  2. "All-zero metrics" holds only without include_confusion_matrix=True. With it, evaluator_format=True output gives the right cm_f1 (0.667) but weighted_overall_score 0.0 instead of 0.5, because that output carries overall, not overall_score (:297). That case is easier to miss than all zeros.
  3. Merging would close #481 with none of its five edits. Either make them (Guides/Evaluation/README.md:335, bulk-evaluation.md:285, map-reduce-evaluation.md:7, :65, :94), or change the body to Refs #481 and also drop Closes #481 from the commit message. Squash, merge and rebase all carry the commit message onto dev, so the body change alone would still close it.

Smaller

  1. Title (vawsgit's point 4). Release notes are built from merged PR titles grouped by conventional-commit type, so please retitle to something like docs: state what the bulk reduce step accepts. The commit subject already starts with docs: but is cut off at "evaluator format is", so it's worth rewording too.
  2. The README note probably isn't needed once the docs edits are in. README.md:686 sits in the JSON Schema section's "Additional Resources" list, and the README has no bulk-evaluation content around it, so someone working on a reduce step won't find it there. The five doc lines the issue lists are where readers hit this. If you'd like to keep a pointer, see the inline suggestion.
  3. When you make those edits, most of the issue's proposed wording can go in as written. The exception is map-reduce-evaluation.md:94: aggregate_from_comparisons() takes only the list of results and uses the default [ConfidenceAccumulator()], so it never returns bbox_map_metrics. Something like: "It supports confidence metrics when each result was produced as the Requirements above describe. For bounding-box mAP, use BulkStructuredModelEvaluator(accumulators=[ConfidenceAccumulator(), BBoxMAPAccumulator()]) with update_from_comparison_result()." At :65, keep the proposed wording that names both metrics: a BBoxMAPAccumulator replay returns bbox_map_metrics whenever the map step produced field_comparisons, which document_field_comparisons=True, add_confidence_metrics=True and add_bbox_metrics=True each do; lead with document_field_comparisons=True. Please branch from current dev first, since #477 has landed and changed the bullet just above Guides/Evaluation/README.md:335.

Comment thread README.md Outdated
- **Dynamic model creation**: [`docs/StructuredModel_Dynamic_Creation.md`](docs/StructuredModel_Dynamic_Creation.md)
- **Comparator details**: [`src/stickler/comparators/Comparators.md`](src/stickler/comparators/Comparators.md)

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` accept default `compare_with()` outputs (confusion matrix plus field comparisons), not `evaluator_format=True` output. Evaluator-format input is silently accepted and yields all-zero metrics.

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.

If you keep this note, here is a version that matches what the reduce step does:

Suggested change
> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` accept default `compare_with()` outputs (confusion matrix plus field comparisons), not `evaluator_format=True` output. Evaluator-format input is silently accepted and yields all-zero metrics.
> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` take `compare_with(..., include_confusion_matrix=True)` output; a default `compare_with()` result raises `ValueError`. Avoid `evaluator_format=True` output: without `include_confusion_matrix=True` it is accepted silently with all-zero metrics, and with it `weighted_overall_score` is 0 and confidence is lost. Confidence also needs `document_field_comparisons=True` (or `add_confidence_metrics=True`). Bounding-box mAP needs that flag plus `BulkStructuredModelEvaluator(accumulators=[..., BBoxMAPAccumulator()])`, since `aggregate_from_comparisons()` computes confidence only. See [Map/Reduce Evaluation: Requirements](https://awslabs.github.io/stickler/Advanced/map-reduce-evaluation/#requirements).

(The #requirements anchor exists in the published site.)

Signed-off-by: YuuGR1337 <yudhatamvan25@gmail.com>
@YuuGR1337

Copy link
Copy Markdown
Author

Thanks for the review — I've updated the PR to address your feedback. Please take another look when you have a moment.

@vawsgit vawsgit 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.

needs changes

Re-review at 1326a3b, following up my review at 52593cb. The diff against current dev is still only README.md (+2 lines). It merges cleanly. Suite on a test merge with origin/dev: 4552 passed, 13 skipped, 1 xfailed. All numbers come from stickler imported from this PR's src/.

Status of my previous findings

# Finding at 52593cb Status at 1326a3b
1 Note said default compare_with() output is accepted Fixed. The note now says include_confusion_matrix=True is required and quotes the real ValueError. Default output raises it. With the flag, cm_f1 is 0.667.
2 All-zero metrics happen only without the confusion-matrix flag Partly fixed. The weighted_overall_score case is now correct (0.0 instead of 0.5). The all-zero case was removed instead of kept. See the inline comment on README.md:686.
3 Fixes #481 closes #481 with none of its edits made Untouched. See blocker A.
4 PR title is not a Conventional Commits subject Untouched. See blocker B.

Changes needed

A. #481 closes on merge, but none of its five doc edits are made. The PR body says Fixes #481 and the 52593cb commit body says Closes #481. The statements #481 asks to correct are unchanged at this head, for example:

  • This format is what `BulkStructuredModelEvaluator` expects when aggregating results across many documents.
    still says evaluator format "is what BulkStructuredModelEvaluator expects".
  • docs/docs/Guides/Evaluation/bulk-evaluation.md:285, and docs/docs/Guides/Evaluation/map-reduce-evaluation.md lines 7, 65 and 94.

Fix: either make the five edits, or change the PR body to Refs #481 and remove Closes #481 from the 52593cb commit message. Merge commits are enabled here, so that commit message reaches dev as written.

B. PR title. Squash merges here use the PR title (COMMIT_OR_PR_TITLE), and the release notes are built from Conventional Commits subjects. Retitle it with a type, for example docs(readme): state what the bulk reduce step accepts. The current title also says "confusion matrix plus field comparisons are required", which the note no longer claims. The 1326a3b subject ("address review feedback on #526") has no type either. That only matters if the PR is not squashed.

C. and D. are inline on README.md:686:

  • C. evaluator_format=True without the confusion-matrix flag gives all-zero metrics and no error.
  • D. document_field_comparisons=True does not produce bounding-box metrics.

Optional, non-blocking

  • The note does not name the alternatives to document_field_comparisons=True (add_confidence_metrics=True and add_bbox_metrics=True), which also work.
  • Placement, from sromoam's review: the note sits after the JSON Schema "Additional Resources" list. Readers working on a reduce step are unlikely to find it there.

Checked and cleared: the requirement and exact ValueError text in the note's first sentence, for both functions. The confidence half of the second sentence. The overall vs overall_score explanation (the reduce step reads only overall_score, at bulk_structured_model_evaluator.py:297). tests/test_readme_examples.py passes. The stale base reverts nothing. The PR adds no tests, so there was nothing to mutation-test.

Comment thread README.md Outdated
- **Dynamic model creation**: [`docs/StructuredModel_Dynamic_Creation.md`](docs/StructuredModel_Dynamic_Creation.md)
- **Comparator details**: [`src/stickler/comparators/Comparators.md`](src/stickler/comparators/Comparators.md)

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` require `compare_with(include_confusion_matrix=True)` output; the default `compare_with()` output is rejected (`ValueError: comparison_result missing 'confusion_matrix' key`). For confidence and bounding-box metrics, also pass `document_field_comparisons=True`. With `evaluator_format=True`, confusion-matrix metrics may appear correct but `weighted_overall_score` is silently wrong because that format carries `overall` instead of `overall_score`.

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.

C (medium): evaluator_format=True without include_confusion_matrix=True gives all-zero metrics, with no error.

Evaluator-format output always has a confusion_matrix key, so the ValueError quoted in this note never fires for it. That contradicts the note's first sentence. "confusion-matrix metrics may appear correct" is true only if the reader also passes include_confusion_matrix=True. Evaluator-format output also loses confidence metrics, even with document_field_comparisons=True.

Measured at this head. Each result was serialized to JSON and loaded back, then passed to aggregate_from_comparisons. The document has two fields, one right:

evaluator_format=True                                → cm_f1 0.0,   weighted_overall_score 0.0   (no error)
evaluator_format=True, include_confusion_matrix=True → cm_f1 0.667, weighted_overall_score 0.0
include_confusion_matrix=True                        → cm_f1 0.667, weighted_overall_score 0.5

Suggested fix: say that evaluator-format output is accepted without an error, gives all-zero metrics unless include_confusion_matrix=True is also set, always gives a wrong weighted_overall_score, and never gives confidence metrics.

Comment thread README.md Outdated
- **Dynamic model creation**: [`docs/StructuredModel_Dynamic_Creation.md`](docs/StructuredModel_Dynamic_Creation.md)
- **Comparator details**: [`src/stickler/comparators/Comparators.md`](src/stickler/comparators/Comparators.md)

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` require `compare_with(include_confusion_matrix=True)` output; the default `compare_with()` output is rejected (`ValueError: comparison_result missing 'confusion_matrix' key`). For confidence and bounding-box metrics, also pass `document_field_comparisons=True`. With `evaluator_format=True`, confusion-matrix metrics may appear correct but `weighted_overall_score` is silently wrong because that format carries `overall` instead of `overall_score`.

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.

D (medium): "For confidence and bounding-box metrics, also pass document_field_comparisons=True" is wrong for bounding boxes.

aggregate_from_comparisons() builds a default BulkStructuredModelEvaluator() (

"""
evaluator = BulkStructuredModelEvaluator()
for result in comparison_results:
evaluator.update_from_comparison_result(result)
return evaluator.compute()
). The default accumulator list holds only ConfidenceAccumulator (
if accumulators is not None:
self._accumulators = accumulators
else:
self._accumulators = [ConfidenceAccumulator(metrics=confidence_metrics)]
). So bounding-box metrics never come out of aggregate_from_comparisons(), and they come out of update_from_comparison_result() only when the evaluator is built with a BBoxMAPAccumulator. A reader who follows the note gets no bounding-box metrics and no error.

Measured with include_confusion_matrix=True, document_field_comparisons=True:

update_from_comparison_result, default accumulators           → accumulator_metrics ['confidence_metrics']
update_from_comparison_result, [Confidence, BBoxMAP] accums   → accumulator_metrics ['bbox_map_metrics', 'confidence_metrics']
aggregate_from_comparisons                                    → accumulator_metrics ['confidence_metrics']

Suggested fix: say bounding-box metrics need BulkStructuredModelEvaluator(accumulators=[ConfidenceAccumulator(), BBoxMAPAccumulator()]), and that aggregate_from_comparisons() computes confidence metrics only. sromoam's inline suggestion on this line already has this wording.

Signed-off-by: YuuGR1337 <yudhatamvan25@gmail.com>
@YuuGR1337

Copy link
Copy Markdown
Author

Thanks for the review — I've updated the PR to address your feedback. Please take another look when you have a moment.

@vawsgit vawsgit 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.

needs changes

Re-review at e61f3b4, following up my review at 1326a3b. The diff against current dev (0855590) is still only README.md (+2 lines), and it merges cleanly. All numbers come from stickler imported from this PR's src/. The same numbers came out on dev with the PR diff applied.

Status of my previous findings

# Finding at 1326a3b Status at e61f3b4
A Fixes #481 closes #481 with none of its edits made Untouched.
B PR title is not a Conventional Commits subject Untouched.
C evaluator_format=True without the confusion-matrix flag gives all-zero metrics with no error Partly fixed. The evaluator_format=True, include_confusion_matrix=True sentence is now correct. The flag-less case is still missing. See the inline comment on README.md:686.
D document_field_comparisons=True does not produce bounding-box metrics Untouched. See the inline comment on README.md:686.

Changes needed

A. #481 closes on merge, but none of its five doc edits are made. The PR body says Fixes #481 and the 52593cb commit body says Closes #481. The statements #481 asks to correct are unchanged on current dev:

Fix: either make the five edits, or change the PR body to Refs #481 and remove Closes #481 from the 52593cb commit message.

B. PR title. Squash merges here use the PR title (squash_merge_commit_title: COMMIT_OR_PR_TITLE), and release notes are built from Conventional Commits subjects. Retitle it with a type, for example docs(readme): state what the bulk reduce step accepts. The title also says "confusion matrix plus field comparisons are required". The note now says the opposite: "With include_confusion_matrix=True alone, confusion-matrix metrics (e.g. cm_f1) work correctly."

C. and D. are inline on README.md:686.

Optional, non-blocking

  • The commit subjects have no type: 52593cb is cut off at "evaluator format is", and 1326a3b and e61f3b4 are "address review feedback on #526". This matters only if the PR is merged without squashing.
  • Placement, from sromoam's review: the note sits after the JSON Schema "Additional Resources" list, away from any bulk-evaluation content.

Checked and cleared

  • The first sentence: default compare_with() output raises ValueError: comparison_result missing 'confusion_matrix' key from both functions.
  • "With include_confusion_matrix=True alone, confusion-matrix metrics work correctly": cm_f1 0.667 and weighted_overall_score 0.5, matching the in-memory update(gt, pred) reference.
  • Confidence with document_field_comparisons=True or add_confidence_metrics=True: both give confidence_metrics through both functions, so the new parenthetical is correct for confidence.
  • The evaluator_format=True, include_confusion_matrix=True sentence: confusion-matrix counts and field_metrics equal the default format, and weighted_overall_score is 0.0 where it should be 0.5. The stated cause is right: the reduce step reads only overall_score (
    if "overall_score" in comparison_result:
    self._accumulate_overall_score(comparison_result["overall_score"])
    ).
  • Stale base: dev is about 20 commits ahead; git merge-tree is clean and nothing is reverted.
  • Tests: tests/test_readme_examples.py 11 passed. Full suite on dev with the diff applied: 5567 passed, 13 skipped, 1 xfailed.
  • The PR adds no tests, so there was nothing to mutation-test.

Comment thread README.md
- **Dynamic model creation**: [`docs/StructuredModel_Dynamic_Creation.md`](docs/StructuredModel_Dynamic_Creation.md)
- **Comparator details**: [`src/stickler/comparators/Comparators.md`](src/stickler/comparators/Comparators.md)

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` require `compare_with(include_confusion_matrix=True)` output; the default `compare_with()` output is rejected (`ValueError: comparison_result missing 'confusion_matrix' key`). With `include_confusion_matrix=True` alone, confusion-matrix metrics (e.g. `cm_f1`) work correctly. For confidence and bounding-box metrics, also pass `document_field_comparisons=True` (or `add_confidence_metrics=True`). With `evaluator_format=True, include_confusion_matrix=True`, confusion-matrix metrics are correct but `weighted_overall_score` is silently 0.0 (the correct value is non-zero) because that format carries `overall` instead of `overall_score`.

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.

C (medium, partly fixed): evaluator_format=True without include_confusion_matrix=True still gives all-zero metrics with no error, and the note does not say so.

The evaluator_format=True, include_confusion_matrix=True sentence is now correct. But evaluator-format output always has a confusion_matrix key (['confusion_matrix', 'fields', 'non_matches', 'overall']), so the ValueError this note quotes never fires for it. A reader who passes only evaluator_format=True gets zeros and no warning. Evaluator format also never yields confidence metrics, even with document_field_comparisons=True or add_confidence_metrics=True.

Measured at this head. Two-field document, one field right, each result serialized to JSON and loaded back, then passed to aggregate_from_comparisons:

evaluator_format=True                                          -> cm_f1 0.0,   weighted_overall_score 0.0, confidence None, no error
evaluator_format=True, include_confusion_matrix=True           -> cm_f1 0.667, weighted_overall_score 0.0, confidence None
evaluator_format=True, include_confusion_matrix=True, dfc=True -> cm_f1 0.667, weighted_overall_score 0.0, confidence None
include_confusion_matrix=True                                  -> cm_f1 0.667, weighted_overall_score 0.5

Suggested fix: say that evaluator_format=True output is accepted without an error, gives all-zero metrics unless include_confusion_matrix=True is also set, always gives a wrong weighted_overall_score, and never gives confidence metrics.

Comment thread README.md
- **Dynamic model creation**: [`docs/StructuredModel_Dynamic_Creation.md`](docs/StructuredModel_Dynamic_Creation.md)
- **Comparator details**: [`src/stickler/comparators/Comparators.md`](src/stickler/comparators/Comparators.md)

> **Bulk reduce input:** `update_from_comparison_result()` and `aggregate_from_comparisons()` require `compare_with(include_confusion_matrix=True)` output; the default `compare_with()` output is rejected (`ValueError: comparison_result missing 'confusion_matrix' key`). With `include_confusion_matrix=True` alone, confusion-matrix metrics (e.g. `cm_f1`) work correctly. For confidence and bounding-box metrics, also pass `document_field_comparisons=True` (or `add_confidence_metrics=True`). With `evaluator_format=True, include_confusion_matrix=True`, confusion-matrix metrics are correct but `weighted_overall_score` is silently 0.0 (the correct value is non-zero) because that format carries `overall` instead of `overall_score`.

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.

D (medium, untouched): "For confidence and bounding-box metrics, also pass document_field_comparisons=True (or add_confidence_metrics=True)" is wrong for bounding boxes.

aggregate_from_comparisons() builds a default BulkStructuredModelEvaluator() (

"""
evaluator = BulkStructuredModelEvaluator()
for result in comparison_results:
evaluator.update_from_comparison_result(result)
). The default accumulator list holds only ConfidenceAccumulator (
self._accumulators = accumulators
else:
self._accumulators = [ConfidenceAccumulator(metrics=confidence_metrics)]
). So aggregate_from_comparisons() never returns bounding-box metrics, whichever flag is passed. update_from_comparison_result() returns them only when the evaluator is built with a BBoxMAPAccumulator. A reader who follows the note gets no bounding-box metrics and no error.

Measured at this head, with include_confusion_matrix=True:

aggregate_from_comparisons, dfc / acm / add_bbox_metrics            -> accumulator_metrics ['confidence_metrics']
update_from_comparison_result, default accumulators, dfc            -> accumulator_metrics ['confidence_metrics']
update_from_comparison_result, [Confidence, BBoxMAP] accums, dfc    -> accumulator_metrics ['bbox_map_metrics', 'confidence_metrics']
update_from_comparison_result, [Confidence, BBoxMAP] accums, acm    -> accumulator_metrics ['bbox_map_metrics', 'confidence_metrics']

Suggested fix: say that bounding-box metrics need BulkStructuredModelEvaluator(accumulators=[ConfidenceAccumulator(), BBoxMAPAccumulator()]) with update_from_comparison_result(), and that aggregate_from_comparisons() computes confidence metrics only. sromoam's inline suggestion on this line already has this wording.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State what the bulk reduce step accepts: evaluator format is not bulk input, and confusion matrix plus field comparisons are required

4 participants