Skip to content

Add delete-d option to the observational relate influence gate#467

Merged
kgdunn merged 2 commits into
mainfrom
claude/robust-relate-delete-d-ksh78i
Jul 23, 2026
Merged

Add delete-d option to the observational relate influence gate#467
kgdunn merged 2 commits into
mainfrom
claude/robust-relate-delete-d-ksh78i

Conversation

@kgdunn

@kgdunn kgdunn commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • The leave-one-out influence gate on marginal associations has a known blind spot at two supporting observations: a correlation carried by exactly two points survives, because 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.
    • 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 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; only the influence_robust decision generalizes. The setting is echoed in result.config["influence_deletions"]. No threshold is introduced - the rule reuses the existing alpha, the number of observations, and d.

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 survives d = 1 but is demoted at d = 2, while a genuine broad driver survives both; the pipeline-level influence_deletions=2 demotes a two-product spike the default gate keeps; max_deletions=0 raises.
  • Verified on synthetic and real sparse data: at d = 2 every association resting on one or two products (and the three-support ones) is demoted, while genuine multi-product drivers survive; d = 1 results are unchanged.
  • uv run ruff check . passes.
  • uv run mypy src/process_improve passes.

Checklist

  • Version bumped in pyproject.toml (MINOR: 1.56.0 -> 1.57.0, new opt-in parameter; CITATION.cff synced)
  • Tests added or updated where relevant
  • ruff check . passes
  • CHANGELOG.md updated

🤖 Generated with Claude Code

https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq


Generated by Claude Code

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

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

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
@kgdunn
kgdunn merged commit 3d4d3c0 into main Jul 23, 2026
14 checks passed
@kgdunn
kgdunn deleted the claude/robust-relate-delete-d-ksh78i branch July 23, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants