Add delete-d option to the observational relate influence gate#467
Merged
Conversation
Leave-one-out cannot demote a correlation carried by exactly two observations: deleting either one leaves the other holding it up, so the jackknife interval never spans zero. Add an `influence_deletions` parameter (default 1) to `analyze_descriptive` / `relate_observational` that sets how many observations the marginal jackknife removes together. For d = 1 the behaviour is unchanged (the shipped leave-one-out jackknife-t). For d >= 2 the averaged jackknife variance would dilute the single subset that removes both supporting points, so the decision switches to a breakdown criterion: the correlation must stay significant, with the same sign, after removing every subset of d observations. A two-support spike is then demoted while a driver supported by more than d observations is kept. The reported `jackknife_se` remains the ordinary leave-one-out standard error. Verified on synthetic and real sparse data: at d = 2 every association resting on one or two products is demoted, while genuine multi-product drivers survive. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Add a unit test exercising the two `_survives_all_deletions` exits that the existing spike tests did not reach: a moderate continuous correlation that stays the same sign but drops below significance when its two most influential points are removed, and a correlation created by two extreme points that reverses sign once they are deleted. Both are robust at d = 1 and demoted at d = 2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
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
influence_deletionsparameter (default1) toanalyze_descriptive/relate_observationalthat sets how many observations the marginal jackknife removes together.d = 1: unchanged - the shipped leave-one-out jackknife-t decision (byte-identical; all prior tests pass).d >= 2: the averaged jackknife variance would dilute the single subset that removes both supporting points, so the decision switches to a breakdown criterion - the correlation must stay significant, with the same sign, after removing every subset ofdobservations. A two-support spike is then demoted while a driver supported by more thandobservations is kept.jackknife_seremains the ordinary leave-one-out standard error; only theinfluence_robustdecision generalizes. The setting is echoed inresult.config["influence_deletions"]. No threshold is introduced - the rule reuses the existingalpha, the number of observations, andd.Test plan
uv run pytest tests/test_sensory.py tests/test_sensory_end_to_end.py --no-cov(49 passed). New tests: a two-support spike survivesd = 1but is demoted atd = 2, while a genuine broad driver survives both; the pipeline-levelinfluence_deletions=2demotes a two-product spike the default gate keeps;max_deletions=0raises.d = 2every association resting on one or two products (and the three-support ones) is demoted, while genuine multi-product drivers survive;d = 1results are unchanged.uv run ruff check .passes.uv run mypy src/process_improvepasses.Checklist
pyproject.toml(MINOR:1.56.0->1.57.0, new opt-in parameter;CITATION.cffsynced)ruff check .passesCHANGELOG.mdupdated🤖 Generated with Claude Code
https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
Generated by Claude Code