Repository navigation
docs: correct the mean_score docstring and the [Plain, NoteSM] table row (#249, #338) #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
07af8aa
3aa363c
12135c6
b79f0e8
18c241d
8fe2c03
a8e42a8
e9bf36d
f498854
633ce69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Guides: leaves and primitive lists anywhere inside a List[StructuredModel] element have no mean_score, and every path inside an element counts only pairs that met the match threshold (a pair below it emits no element fields). - _accumulate_field_metrics docstring: same scope, replacing "leaves under a list parent". - _ClassGatedComparator and test-class docstrings: both [Plain, NoteSM] rows enforced the cross-class rule under the list-wide gate (bare fd=2). - Pin the bare row: [Plain] vs [Plain] = 0.0, bare [Plain, NoteA] vs [Plain, NoteB] = 0.5 (tp=1, fd=1). - Fix the two surviving "emits only at the list parent" comments in test_bulk_structured_model_evaluator.py. - CHANGELOG: Unreleased Documentation entry for the mean_score guide fix.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,15 @@ Each release links to full notes on the | |
|
|
||
| ### Documentation | ||
|
|
||
| - Corrected which paths in `BulkStructuredModelEvaluator` `field_metrics` get a | ||
| `mean_score`. The guides said `compare_with()` scores only the list parent of a | ||
| `List[StructuredModel]`. An object inside a list element (`items.addr`) is | ||
| scored too. Leaves and primitive lists anywhere inside an element | ||
| (`items.name`, `items.addr.city`, `items.tags`) carry confusion-matrix counts | ||
| but no `mean_score`, and only from element pairs that met the match | ||
| threshold: a pair below it emits no element fields at all. Scoring is | ||
| unchanged ([#249](https://github.com/awslabs/stickler/issues/249)) | ||
|
|
||
| - Corrected the last row of the 1.0.0 table under "The element gate judges a | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low, optional.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| PAIR, not a list". Under its bare `Optional[List[Any]]` heading, | ||
| `[Plain, NoteSM]` vs `[Plain, Note2SM]` scores `0.5`, not `1.0`, and scored | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,7 +139,7 @@ Because each document's `overall_score = Σ_f(score × weight) / Σ_f(weight)` a | |
|
|
||
| The denominator is the count of documents whose `overall_score` was a finite number: error docs (`update()` raised) and successful docs carrying a non-finite or missing `overall_score` are both excluded. With zero eligible documents the score is `0.0` — disambiguate via `document_count` when that matters. | ||
|
|
||
| Per-field `mean_score` is reported at every nested path (leaf and object/list aggregate) where `threshold_applied_score` was observed in at least one document, averaging over just those documents. Paths with confusion-matrix counts but no score data (e.g., leaves inside `List[StructuredModel]`, which `compare_with()` emits without a score) are surfaced without a `mean_score` key rather than reported as `0.0`. | ||
| Per-field `mean_score` is reported at every nested path (leaf and object/list aggregate) where `threshold_applied_score` was observed in at least one document, averaging over just those documents. Paths with confusion-matrix counts but no score data (leaves and primitive lists anywhere inside a `List[StructuredModel]` element, such as `items.name`, `items.addr.city` or `items.tags`) are surfaced without a `mean_score` key rather than reported as `0.0`. Every path inside an element, scored or not, counts only element pairs that met the match threshold: `compare_with()` emits no element fields for a pair below it. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same inaccuracy as CHANGELOG.md:197: object nodes two or more levels inside an element (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| --- | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -402,7 +402,7 @@ This is useful for comprehensive auditing of all comparisons, not just failures. | |
| The per-document `overall_score` above is a weighted average of field scores. When you aggregate across many documents with `BulkStructuredModelEvaluator.compute()`, the weight information is preserved via two keys: | ||
|
|
||
| - **`metrics["weighted_overall_score"]`** (float) -- Arithmetic mean of each document's `overall_score`. Prefer this over `cm_f1` whenever your schema uses non-uniform `ComparableField(weight=...)` values: `cm_f1` treats every field-match equally, while `weighted_overall_score` preserves the declared per-field weights across the dataset. | ||
| - **`field_metrics[path]["mean_score"]`** (float, when present) -- Arithmetic mean of each document's `threshold_applied_score` at that path, reported at every nested node that was actually scored. Paths with confusion-matrix counts but no score data (e.g., leaves inside `List[StructuredModel]`, which `compare_with()` emits without a score) are surfaced without a `mean_score` key rather than as `0.0`. | ||
| - **`field_metrics[path]["mean_score"]`** (float, when present) -- Arithmetic mean of each document's `threshold_applied_score` at that path, reported at every nested node that was actually scored. Paths with confusion-matrix counts but no score data (leaves and primitive lists anywhere inside a `List[StructuredModel]` element, such as `items.name`, `items.addr.city` or `items.tags`) are surfaced without a `mean_score` key rather than as `0.0`. Every path inside an element, scored or not, counts only element pairs that met the match threshold: `compare_with()` emits no element fields for a pair below it. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same inaccuracy as CHANGELOG.md:197: object nodes two or more levels inside an element (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 633ce69, same wording as |
||
|
|
||
| ```python | ||
| from stickler.structured_object_evaluator.bulk_structured_model_evaluator import ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -460,8 +460,11 @@ def _accumulate_field_metrics( | |
| fields of a list of StructuredModel, so CM counts are recorded at | ||
| every node compare_with emits. Score sums (for ``mean_score``) are | ||
| recorded only where a node carries a finite | ||
| ``threshold_applied_score``. Leaves under a list parent carry CM | ||
| counts only, so their paths get no ``mean_score`` (see #249). | ||
| ``threshold_applied_score``. Leaves anywhere inside a list element, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same inaccuracy as CHANGELOG.md:197: this docstring omits object nodes two or more levels inside an element (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 633ce69. The docstring names the same sets and says the score is copied from the first matched pair. |
||
| and primitive lists inside a list element, carry CM counts only, so | ||
| their paths get no ``mean_score`` (see #249). An element pair below | ||
| the match threshold emits no element fields, so every path inside an | ||
| element counts matched pairs only. | ||
| ``nested_fields`` is also walked, but compare_with no longer emits it. | ||
| """ | ||
| for field_name, field_data in fields_dict.items(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocker (the docs are still inaccurate): deeper object nodes inside a list element have no
mean_score.Order.items: List[Line],Line.addr: Addr,Addr.geo: Geo. On this PR merged with dev:field_metrics['items.addr']hasmean_score1.0.items.addr.geo,items.opt_addr.geoanditems.parts.lochave tp>0 and nomean_score.ship.geo, outside a list, does have one.So "An object inside a list element (
items.addr) is scored too" holds only one level deep, and "leaves and primitive lists" is not the full unscored set.Also, the
items.addrvalue is copied frompair_results[0](structured_list_comparator.py:368). With gtitems=[A, B]and pred[A, B'], where B' differs from B only inaddr,mean_scoreis 1.0. The same content reordered ([B, A]vs[B', A]) gives 0.0, against a two-pair mean of 0.5. Say that this value reflects the first matched pair, not a mean over pairs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, confirmed and fixed in 633ce69. Measured on this branch: inside a
List[StructuredModel]element, only the element's ownStructuredModelandList[StructuredModel]fields (items.addr,items.parts) get amean_score. Everything deeper (items.addr.geo,items.parts.sku), a plainBaseModelfield, and every leaf or primitive list inside an element have counts only. The value is the first matched pair's score, so it depends on element order; that's #428, now linked.test_list_of_model_leaf_omits_mean_score_keypins both sets.