Fix D4: pseudocount formula#2514
Open
jucor wants to merge 1 commit into
Open
Conversation
This was referenced Mar 30, 2026
603f0ac to
b9dcc89
Compare
ballPointPenguin
approved these changes
Apr 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Delphi’s representativeness (“repness”) probability smoothing constant to match Clojure’s implementation, so computed pa/pd values align exactly across languages.
Changes:
- Set
PSEUDO_COUNTto2.0inrepness.pyand update the explanatory comment. - Un-xfail D4 discrepancy tests now that the constant matches Clojure.
- Remove remaining hardcoded
1.5pseudocount usage in unit/compat tests (importPSEUDO_COUNTinstead) and update the simplified repness script constant.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| delphi/polismath/pca_kmeans_rep/repness.py | Change pseudocount constant to 2.0 and update inline rationale. |
| delphi/tests/test_discrepancy_fixes.py | Remove xfails for D4 tests that now pass with updated pseudocount. |
| delphi/tests/test_repness_unit.py | Use PSEUDO_COUNT constant in expected-value calculation instead of hardcoding. |
| delphi/tests/test_old_format_repness.py | Same: import and use PSEUDO_COUNT for expected pa/pd. |
| delphi/tests/simplified_repness_test.py | Update the simplified script’s hardcoded pseudocount to 2.0. |
| delphi/docs/PLAN_DISCREPANCY_FIXES.md | Mark D4 pseudocount fix as done. |
| delphi/docs/HANDOFF_REGRESSION_TEST_PERF.md | Add handoff doc summarizing regression test perf investigation. |
| delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md | Journal entry documenting the D4 fix and perf side investigation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+26
to
+30
| # - With PSEUDO_COUNT = 2.0, we add 1 "virtual" agree and 1 "virtual" disagree | ||
| # to each comment's vote count — equivalent to a Beta(2,2) prior | ||
| # - This pulls probabilities toward 0.5, with the effect diminishing as n grows | ||
| # - Formula: p_agree = (n_agree + PSEUDO_COUNT/2) / (n_votes + PSEUDO_COUNT) | ||
| # i.e. (n_agree + 1) / (n_votes + 2) |
Comment on lines
18
to
21
| # Constants | ||
| Z_90 = 1.645 # Z-score for 90% confidence | ||
| PSEUDO_COUNT = 1.5 # Pseudocount for Bayesian smoothing | ||
| PSEUDO_COUNT = 2.0 # Pseudocount for Bayesian smoothing (Beta(2,2) prior, matches Clojure) | ||
|
|
## Summary - Change `PSEUDO_COUNT` from 1.5 to 2.0, matching Clojure's Beta(2,2) prior - This changes probability smoothing from `pa = (na + 0.75)/(ns + 1.5)` to `pa = (na + 1)/(ns + 2)` - All `pa`/`pd` values now match Clojure's `p-success` exactly (verified on all datasets with Clojure blobs) ## Changes - `repness.py`: `PSEUDO_COUNT = 2.0` with updated comment - `test_discrepancy_fixes.py`: remove xfail from 3 D4 tests (constant check, pa values per dataset, synthetic) - `test_repness_unit.py`, `test_old_format_repness.py`: import `PSEUDO_COUNT` instead of hardcoding 1.5 - `simplified_repness_test.py`: update hardcoded constant - Golden snapshots re-recorded for public datasets (vw, biodiversity) ## Test plan - [x] TDD red: 6 D4 tests fail before fix - [x] TDD green: all 6 D4 tests pass after fix - [x] Full public suite: 258 passed, 0 failures - [x] Private datasets (--include-local): 60 passed, 0 failures (discrepancy tests) - [x] Regression tests pass on public + FLI + bg2018 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Squashed commits - Fix D4: PSEUDO_COUNT 1.5 → 2.0 to match Clojure's Beta(2,2) prior - Journal: add session 6 (D4 fix), update plan marking D4 done commit-id:6ae3ee43
Delphi Coverage Report
|
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
PSEUDO_COUNTfrom 1.5 to 2.0, matching Clojure's Beta(2,2) priorpa = (na + 0.75)/(ns + 1.5)topa = (na + 1)/(ns + 2)pa/pdvalues now match Clojure'sp-successexactly (verified on all datasets with Clojure blobs)Changes
repness.py:PSEUDO_COUNT = 2.0with updated commenttest_discrepancy_fixes.py: remove xfail from 3 D4 tests (constant check, pa values per dataset, synthetic)test_repness_unit.py,test_old_format_repness.py: importPSEUDO_COUNTinstead of hardcoding 1.5simplified_repness_test.py: update hardcoded constantTest plan
🤖 Generated with Claude Code
Squashed commits
commit-id:6ae3ee43
Stack: