Repository navigation
Closure Mode Ablation - #8
Merged
lee-leonardo merged 3 commits intoNov 28, 2026
Merged
Conversation
This was referenced Nov 26, 2026
lee-leonardo
added a commit
that referenced
this pull request
Nov 28, 2026
…ge (#8) Add a reusable audit helper, synthetic semantic checks and a notebook comparing direct Is a traversal with a minimum-separation-one ancestry overlay at fixed root depths, eligibility and target policy. Record input identity, exact edge deltas, structural gaps, typed mapping failures and local path witnesses. On the identified Athena bundle, the overlay adds 334 edges, reduces nodes unreachable from Disease from 190 to 133 and recovers 26 of 33 deep mapping failures under both target policies. Seven deep failures remain. The eligible target vocabulary is unchanged; additional nonempty target sets also change. The base KnowledgeGraph remains direct; the traversal overlay can change successful sample paths. Connectivity and coverage improve on this bundle, but embedding quality and downstream learning effects remain inconclusive.
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
This investigates whether KEEP's existing
path_source="closure"option changes the information available after ontology traversal: does it reconnect concepts that filtered direct relationships leave disconnected, recover failed ancestor mappings, or change the retained targets and paths supplied to later processing?The contribution is a reproducible audit and explanatory notebook around the existing PyHealth readers and roll-up processor. It adds no production behavior or default changes. On one identified Athena bundle, closure improves connectivity and mapping coverage; whether those changes improve embeddings or downstream prediction remains unmeasured.
Start with the notebook, which separates executable synthetic examples from recorded full-release findings.
What is being compared?
Here, “closure” means a specific separation-one ancestry overlay, not every transitive ancestor relationship:
U: the uncut subtree of valid standard SNOMED Condition concepts under Disease, OMOP concept4274025.D: filtered directIs aedges whose endpoints are inU, oriented parent → child.P: uniqueCONCEPT_ANCESTORpairs whose minimum separation is exactly one, with both endpoints inU.D; closure traversal followsD ∪ P. Existing direct-edge provenance wins where the sets overlap.first_retainedandall_retainedon_unmapped="empty"preserves typed failures for counting; the production default remains"error"U, once per mode and policyThe distinction between graph layers matters: the factory's base KnowledgeGraph remains direct in both modes. The processor's traversal index receives the overlay, and projected sample graphs may include those additional successful paths. The audit does not edit the Athena export. An embedding trainer consuming only the unchanged base graph would not automatically receive the overlay.
What the audit measures
The helper independently extracts the direct and separation-one edge sets through public reader tables, checks factory provenance and target eligibility, then maps every subtree concept in bounded deterministic batches. It records:
no_targetfailures, lost mappings, and residual failures. Eligible identity mappings and excluded-root failures are counted separately from deep-source outcomes.Synthetic check
The invented fixture has 12 subtree concepts, six eligible targets and five deep sources. Direct traversal has nine edges; closure adds two.
One new edge recovers a previously unmapped deep source. Another adds a branch-local
first_retainedtarget even thoughall_retainedalready reaches that target through another path. A separate filtered-intermediate example remains unmapped because repairing it would require a longer ancestry shortcut.For either policy, deep failures fall from 2/5 to 1/5. Across all 12 concepts, failures fall from three to two, including the expected excluded root. These are hand-specified correctness examples, not estimates of clinical prevalence or a simulated full Athena release.
Recorded Athena results
The full-subtree audit was run on 2026-11-25 against OMOP Standardized Vocabularies
v5.0 29-AUG-26. The supplied bundle identifies SNOMED International2026-02-01, US2026-03-01, and UK2026-04-08. The notebook records table hashes and environment details. These observations cover this bundle's Disease subtree, not every Athena vocabulary or release.The 334 additional edges are 0.162% of the direct edge count. Their importance cannot be inferred from that fraction alone.
first_retainedall_retainedno_targetBoth policies recover 26 of 33 deep failures (78.8%). The concept-level deep mapping failure rate falls from 0.142% to 0.030%, an absolute decrease of 0.112 percentage points. This is a full Athena-bundle observation, distinct from the synthetic check above. It measures mapping reachability, not semantic accuracy or patient-level coverage.
Seven deep failures remain. A separate diagnostic scan found eligible ancestors at separations three to five for all seven, but no selected traversal path reaches them. This shows the limits of a separation-one overlay; it does not establish that an orphan-rescue algorithm would repair every residual case.
Interpretation and limits
Closure can change coverage, represented targets and topology. Identical target sets can still hide different successful paths and therefore different projected graph inputs. The current census measures mapping outcomes across
U, with selected graph witnesses; it does not yet enumerate all projected-graph changes or measure diagnosis-weighted exposure, co-occurrence changes, trained embeddings or predictive benefit.More connectivity does not establish better representations. Next steps documented in the notebook include independent synthetic graph references, paired projected-graph comparisons, cutoff sensitivity, sample-level exposure and a separately scoped learning experiment. These are proposed extensions, not completed results. Neither target policy is certified against the original authors' artifact here.
Changes / additions
examples/keep_closure_mode_audit.pyexamples/keep_closure_mode_audit.ipynbtests/core/test_keep_closure_mode_audit.pyThis is separate from the ontology-loading optimization in #7. The recorded measurements used production baseline
33c2cb6, before that optimization, and should not be attributed to its performance changes. The audit can inform the choice of traversal configuration for the depth experiment in #9; it does not require changing that PR's reference before the branches merge.Run it
From the PyHealth repository root:
The helper writes
summary.json, per-policy difference/failure TSVs and path witnesses locally. Real input requires--athena-dir; there is no automatic dataset discovery or download. Keep licensed input and release-specific row exports local.Validation record
AI assistance
OpenAI Codex assisted with the audit implementation, synthetic tests, notebook explanations, analysis and this description. The contributor directed the investigation's questions and scope. The numerical results above come from the recorded audit runs; AI-assisted interpretation does not establish clinical benefit or independent confirmation of the original KEEP implementation.