Repository navigation
State what the bulk reduce step accepts: evaluator format is not bulk input, and confusion matrix plus field comparisons are required - #526
Conversation
Closes awslabs#481 Signed-off-by: YuuGR1337 <yudhatamvan25@gmail.com>
|
Thanks @YuuGR1337, taking this; full review after the release work. Heads-up from a first pass: #481 asks for specific fixes in |
vawsgit
left a comment
There was a problem hiding this comment.
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.
Lines 685 to 687 in 52593cb
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
left a comment
There was a problem hiding this comment.
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:
- Default
compare_with()output is rejected, not accepted.update_from_comparison_result()andaggregate_from_comparisons()both raiseValueError: comparison_result missing 'confusion_matrix' key(bulk_structured_model_evaluator.py:284). They needinclude_confusion_matrix=True, as their docstrings say. - "All-zero metrics" holds only without
include_confusion_matrix=True. With it,evaluator_format=Trueoutput gives the rightcm_f1(0.667) butweighted_overall_score0.0 instead of 0.5, because that output carriesoverall, notoverall_score(:297). That case is easier to miss than all zeros. - 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 toRefs #481and also dropCloses #481from the commit message. Squash, merge and rebase all carry the commit message ontodev, so the body change alone would still close it.
Smaller
- 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 withdocs:but is cut off at "evaluator format is", so it's worth rewording too. - The README note probably isn't needed once the docs edits are in.
README.md:686sits 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. - 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 returnsbbox_map_metrics. Something like: "It supports confidence metrics when each result was produced as the Requirements above describe. For bounding-box mAP, useBulkStructuredModelEvaluator(accumulators=[ConfidenceAccumulator(), BBoxMAPAccumulator()])withupdate_from_comparison_result()." At:65, keep the proposed wording that names both metrics: aBBoxMAPAccumulatorreplay returnsbbox_map_metricswhenever the map step producedfield_comparisons, whichdocument_field_comparisons=True,add_confidence_metrics=Trueandadd_bbox_metrics=Trueeach do; lead withdocument_field_comparisons=True. Please branch from currentdevfirst, since #477 has landed and changed the bullet just aboveGuides/Evaluation/README.md:335.
| - **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. |
There was a problem hiding this comment.
If you keep this note, here is a version that matches what the reduce step does:
| > **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>
|
Thanks for the review — I've updated the PR to address your feedback. Please take another look when you have a moment. |
vawsgit
left a comment
There was a problem hiding this comment.
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:
- still says evaluator format "is what
stickler/docs/docs/Guides/Evaluation/README.md
Lines 334 to 336 in 1326a3b
BulkStructuredModelEvaluatorexpects". docs/docs/Guides/Evaluation/bulk-evaluation.md:285, anddocs/docs/Guides/Evaluation/map-reduce-evaluation.mdlines 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=Truewithout the confusion-matrix flag gives all-zero metrics and no error. - D.
document_field_comparisons=Truedoes not produce bounding-box metrics.
Optional, non-blocking
- The note does not name the alternatives to
document_field_comparisons=True(add_confidence_metrics=Trueandadd_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.
| - **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`. |
There was a problem hiding this comment.
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.
| - **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`. |
There was a problem hiding this comment.
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() (
stickler/src/stickler/structured_object_evaluator/bulk_structured_model_evaluator.py
Lines 1028 to 1032 in 1326a3b
ConfidenceAccumulator (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>
|
Thanks for the review — I've updated the PR to address your feedback. Please take another look when you have a moment. |
vawsgit
left a comment
There was a problem hiding this comment.
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:
- still says "This format is what
stickler/docs/docs/Guides/Evaluation/README.md
Lines 340 to 342 in 0855590
BulkStructuredModelEvaluatorexpects". stickler/docs/docs/Guides/Evaluation/bulk-evaluation.md
Lines 284 to 286 in 0855590
docs/docs/Advanced/map-reduce-evaluation.mdlines 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.
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 raisesValueError: comparison_result missing 'confusion_matrix' keyfrom both functions. - "With
include_confusion_matrix=Truealone, confusion-matrix metrics work correctly":cm_f10.667 andweighted_overall_score0.5, matching the in-memoryupdate(gt, pred)reference. - Confidence with
document_field_comparisons=Trueoradd_confidence_metrics=True: both giveconfidence_metricsthrough both functions, so the new parenthetical is correct for confidence. - The
evaluator_format=True, include_confusion_matrix=Truesentence: confusion-matrix counts andfield_metricsequal the default format, andweighted_overall_scoreis 0.0 where it should be 0.5. The stated cause is right: the reduce step reads onlyoverall_score( ). - Stale base:
devis about 20 commits ahead;git merge-treeis clean and nothing is reverted. - Tests:
tests/test_readme_examples.py11 passed. Full suite ondevwith the diff applied: 5567 passed, 13 skipped, 1 xfailed. - The PR adds no tests, so there was nothing to mutation-test.
| - **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`. |
There was a problem hiding this comment.
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.
| - **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`. |
There was a problem hiding this comment.
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() (
stickler/src/stickler/structured_object_evaluator/bulk_structured_model_evaluator.py
Lines 1028 to 1031 in e61f3b4
ConfidenceAccumulator (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.
Fixes #481