Skip to content

Influence-robust jackknife gate for the observational sensory relate#466

Merged
kgdunn merged 3 commits into
mainfrom
claude/robust-relate-influence-ksh78i
Jul 23, 2026
Merged

Influence-robust jackknife gate for the observational sensory relate#466
kgdunn merged 3 commits into
mainfrom
claude/robust-relate-influence-ksh78i

Conversation

@kgdunn

@kgdunn kgdunn commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Sparse, wide predictor blocks (many descriptors non-zero on only a single observation) let one high-leverage point manufacture a spurious "driver": after unit-variance scaling a lone non-zero becomes a fixed spike, so its entire apparent relationship to a response is a single observation. Such an effect passes a bare FDR gate and survives cross-validation, because the column contributes nothing to any out-of-fold prediction.
  • process_improve.sensory.analyze_descriptive now gates both observational relate paths on an exhaustive leave-one-out jackknife:
    • Marginal associations: attach a Fisher-z jackknife (jackknife_se, influence_robust, n_supporting); significant now requires both Benjamini-Hochberg rejection and jackknife robustness.
    • Discriminator: reuse the LOO refit already run for the Q-squared gate to read Martens' per-coefficient jackknife interval (jackknife_significant); discriminator_significant additionally requires that interval to exclude zero.
  • The jackknife adds no threshold of its own - it reuses the existing alpha and the number of observations - so a genuine multi-observation driver is unaffected while a single-support spike is demoted. It is deterministic (LOO is exhaustive; no RNG). All added record fields are additive; existing keys and their meanings are unchanged.

Test plan

  • uv run pytest tests/test_sensory.py tests/test_sensory_end_to_end.py --no-cov (45 passed). New case study: a single-support spike with a strong in-sample correlation (r ~ 0.99, p < 1e-4) is demoted on both paths, while a smooth multi-product driver stays significant. Verified the demotion is not over-pruning: genuine drivers keep jackknife_significant, and a pre-change comparison shows the discriminator's permutation gate behaviour is unchanged.
  • uv run ruff check . passes.
  • uv run mypy src/process_improve passes (139 files).

Checklist

  • Version bumped in pyproject.toml (MINOR: 1.55.1 -> 1.56.0, behavioural change to relate significance; 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

Sparse, wide predictor blocks (many descriptors non-zero on only a single
product) let a lone high-leverage observation manufacture a "driver": after
unit-variance scaling that single non-zero becomes a fixed spike, so its entire
apparent relationship to a response is one product. Such an effect passes a bare
FDR gate and survives cross-validation, because the column contributes nothing to
any out-of-fold prediction.

Gate both observational relate paths on an exhaustive leave-one-out jackknife:

- Marginal associations: attach a Fisher-z jackknife (`jackknife_se`,
  `influence_robust`, `n_supporting`); `significant` now requires both
  Benjamini-Hochberg rejection and jackknife robustness.
- Discriminator: reuse the LOO refit already run for the Q-squared gate to read
  Martens' per-coefficient jackknife interval (`jackknife_significant`);
  `discriminator_significant` additionally requires that interval to exclude zero.

The jackknife adds no threshold of its own - it reuses the existing `alpha` and
the number of observations - so a genuine multi-observation driver is unaffected
while a single-support spike is demoted. Deterministic (LOO is exhaustive).

Tests add a two-attribute case study: a single-support spike whose in-sample
correlation is strong (r ~ 0.99, p < 1e-4) is demoted, while a smooth
multi-product driver stays significant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

claude added 2 commits July 22, 2026 22:33
A jackknife standard error of exactly zero means every leave-one-out deletion
returns the same correlation, i.e. the association is maximally stable. Treat it
as influence-robust when the correlation is non-zero, instead of the previous
blanket demotion of the zero-spread case. Add unit coverage for the helper's
degenerate branches (too few observations, single-support collapse, zero-spread
perfect correlation), addressing the uncovered patch lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
The `not np.isfinite(se)` guard in the correlation jackknife was dead code: the
correlations are clipped before the Fisher-z transform and the caller guarantees
non-constant inputs, so the jackknife standard error is always finite. Remove it
and note why. Add a small-sample discriminator test so the branch where the
leave-one-out gate is skipped (fewer than five products, jackknife undefined) is
exercised and every descriptor correctly defaults to not-confirmed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018M9u5EpSjHa3mjNaYDJ7qq
@kgdunn
kgdunn merged commit 042fc33 into main Jul 23, 2026
14 checks passed
@kgdunn
kgdunn deleted the claude/robust-relate-influence-ksh78i branch July 23, 2026 05:25
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