Fix D7: match Clojure repness metric formula (product of 4 signed values)#2521
Open
jucor wants to merge 1 commit into
Open
Fix D7: match Clojure repness metric formula (product of 4 signed values)#2521jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Mar 30, 2026
cfd57d1 to
90838d7
Compare
d92e3f2 to
be320d5
Compare
90838d7 to
1390ff7
Compare
ballPointPenguin
approved these changes
Apr 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates discrepancy-tracking documentation to indicate D7 (“Repness metric”) is complete and adds a journal entry describing the D7 TDD steps and implementation details.
Changes:
- Mark D7 as DONE in the discrepancy coverage checklist.
- Add a “PR 6: Fix D7 — Repness Metric Formula” journal section documenting the purported formula change and test workflow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
delphi/docs/PLAN_DISCREPANCY_FIXES.md |
Updates the discrepancy checklist row for D7 to show it as completed. |
delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md |
Adds a journal entry describing the D7 fix steps, formula changes, and testing outcomes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
468
to
473
| | D3 | K-smoother buffer | PR 10 | — | Fix | | ||
| | D4 | Pseudocount formula | **PR 2** | **#2435** | **DONE** ✓ | | ||
| | D5 | Proportion test | **PR 4** | — | **DONE** ✓ | | ||
| | D6 | Two-proportion test | **PR 5** | — | **DONE** ✓ | | ||
| | D7 | Repness metric | PR 6 | — | Fix (with flag for old formula) | | ||
| | D7 | Repness metric | PR 6 | — | **DONE** ✓ | | ||
| | D8 | Finalize cmt stats | PR 7 | — | Fix | |
Comment on lines
+504
to
+520
| 3. **Fix**: Changed both scalar `repness_metric()` and vectorized `compute_group_comment_stats_df()`: | ||
| - agree_metric: `pa * (|pat| + |rat|)` → `ra * rat * pa * pat` | ||
| - disagree_metric: `(1 - pd) * (|pdt| + |rdt|)` → `rd * rdt * pd * pdt` | ||
| 4. **Green**: All 5 D7 formula tests pass + 4 blob comparison xfailed (D10 selection differs) | ||
| 5. **Full suite (public)**: 4 regression failures, all in `repness.group_repness` fields (expected — | ||
| metric reranking changes which comments are selected) | ||
| 6. **Re-recorded golden snapshots** for all 7 datasets (public + private) | ||
| 7. **Final (with --include-local)**: 1 failed (pakistan-incremental D2, pre-existing), 98 passed, | ||
| 5 skipped, 131 xfailed, 3 xpassed — 19/19 regression tests pass | ||
|
|
||
| ### Changes | ||
| - `repness.py`: `repness_metric()` changed from `p_factor * (abs(p_test) + abs(r_test))` to | ||
| `r * r_test * p * p_test`. The old disagree formula was doubly wrong: used `(1-pd)` instead of | ||
| `pd`, and used a weighted sum instead of a product. | ||
| - `repness.py`: Vectorized metric in `compute_group_comment_stats_df()` updated to match. | ||
| - `test_discrepancy_fixes.py`: Expanded `TestD7RepnessMetric` from 2 to 6 tests (5 formula + 1 blob). | ||
| - `test_repness_unit.py`, `test_old_format_repness.py`: Updated expected values to match product formula. |
…ues)
## Summary
Changes the representativeness metric from a weighted sum of absolutes to the
Clojure product formula (repness.clj:188-190).
**Before (Python):**
- agree_metric = `pa * (|pat| + |rat|)` — weighted sum, tolerant of weak factors
- disagree_metric = `(1 - pd) * (|pdt| + |rdt|)` — doubly wrong: uses `(1-pd)` and sum
**After (Clojure formula):**
- agree_metric = `ra * rat * pa * pat` — product of 4 signed values
- disagree_metric = `rd * rdt * pd * pdt` — product of 4 signed values
The product formula is more conservative: any factor near zero kills the entire
metric, requiring ALL dimensions (probability, significance, relative
representativeness) to be strong simultaneously.
The old disagree formula was doubly wrong:
1. Used `(1 - pd)` instead of `pd` — high metric when disagree probability is LOW
2. Used a weighted sum of absolutes instead of a signed product
No feature flag for the old formula — it has no defensible behavior.
## Test plan
- [x] 5 new D7 formula tests (agree product, disagree product, zero-kills-metric,
sign preservation, multiple known values)
- [x] Updated unit tests in test_repness_unit.py and test_old_format_repness.py
- [x] Full test suite passes (excluding DynamoDB/MinIO tests)
- [x] Private dataset tests pass (--include-local)
- [x] Golden snapshots re-recorded for all 7 datasets
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Squashed commits
- Add PR description and update plan/journal for D7 fix
commit-id:80eaa87c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes the representativeness metric from a weighted sum of absolutes to the
Clojure product formula (repness.clj:188-190).
Before (Python):
pa * (|pat| + |rat|)— weighted sum, tolerant of weak factors(1 - pd) * (|pdt| + |rdt|)— doubly wrong: uses(1-pd)and sumAfter (Clojure formula):
ra * rat * pa * pat— product of 4 signed valuesrd * rdt * pd * pdt— product of 4 signed valuesThe product formula is more conservative: any factor near zero kills the entire
metric, requiring ALL dimensions (probability, significance, relative
representativeness) to be strong simultaneously.
The old disagree formula was doubly wrong:
(1 - pd)instead ofpd— high metric when disagree probability is LOWNo feature flag for the old formula — it has no defensible behavior.
Test plan
sign preservation, multiple known values)
🤖 Generated with Claude Code
Squashed commits
commit-id:80eaa87c
Stack: