feat: persist leftover-map unexplained leftover share (ADR 0233) - #750
Conversation
|
Warning Review limit reachedNext included review available in 19 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (28)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| def _leftover_map_unexplained_share(residual: float, reconstruction: float) -> float | None: | ||
| """Return ``s = U² / R²`` when both terms are finite; otherwise omit. | ||
|
|
||
| Unexplained leftover ``U = R − R̂`` is computed internally. | ||
| ``s`` is nonnegative because it is a square share. A rank-0 origin | ||
| cell stores ``0.0`` when ``R = R̂ = U = 0``. A finite share greater | ||
| than 1 is stored when ``|U| > |R|``; do not clamp. | ||
| """ | ||
| if not np.isfinite(residual) or not np.isfinite(reconstruction): | ||
| return None | ||
| unexplained = float(residual - reconstruction) | ||
| if abs(residual) > _LEFTOVER_SINGULAR_FLOOR: | ||
| share = float((unexplained * unexplained) / (residual * residual)) | ||
| return share if np.isfinite(share) else None | ||
| if abs(reconstruction) <= _LEFTOVER_SINGULAR_FLOOR and abs(unexplained) <= _LEFTOVER_SINGULAR_FLOOR: | ||
| return 0.0 | ||
| return None |
There was a problem hiding this comment.
📝 Info: Two share functions stay consistent by construction
_leftover_map_unexplained_share mirrors _leftover_map_cross_share exactly: same finite guards, same floor branches, same 0.0/None returns. A cell yielding a finite unexplained share therefore always yields a finite cross share, so the reordered next-action fallback stays consistent and older null-share rows fall through to cross share.
Was this helpful? React with 👍 or 👎 to provide feedback.
Persist leftover-map unexplained leftover share s = U² / R² of raw residual on leftover post–criterion pairs so the leftover the truncated two-axis map cannot reconstruct is not read as leftover residual R, leftover-map distance d, unexplained leftover U, or leftover-map cross share x. Do not persist leftover-map explained share e. After make seed, closest and farthest leftover pairs sit above the member list with U²/R² next to leftover-map distance d; click opens that post. Missing or non-finite share omits the badge rather than inventing a leftover score. A share greater than 1 is stored, never clamped. The grouping comparison strip stays on its reduced leftover payload (distance, residual, reconstruction). Independent of leftover stacks #640, #680, #720 and dashboard explained share ADR 0232 (#728).
d4f6cfd to
4ed22b3
Compare
Summary
Persist leftover-map unexplained leftover share
s = U² / R²of raw residual on leftover post–criterion pairs (ADR 0233 / migration 0233). Aftermake seed, closest and farthest leftover pairs sit above the member list withU²/R²next to leftover-map distanced; click opens that post.The raw-residual identity
R² = R̂² + U² + 2 R̂ Uyieldse + s + x = 1. ADR 0185 already persistsx; this increment persistssso buyers do not read leftover residualR, leftover-map distanced, or unexplained leftoverUas the leftover the truncated two-axis map cannot reconstruct.leftover_map_unexplained_shareonreport_leftover_pair. Do not add an upper-bound CHECK: a finite share greater than 1 is stored when|U| > |R|.0.0; a rank-0 constant residual withR̂ = 0stores1.0.e. Dashboard explained-share ADR 0232 (feat(leftover): persist leftover-map explained share (ADR 0232) #728 ontofeat/dashboard-case-metrics) stays on that stack.Test plan
pytest tests/test_leftover_pairs.py(23 passed)U²/R²next tod; click opens that post. Hidden posts stay hidden. Comparison strip does not badge unexplained leftover share.Independent APPROVE required. Do not self-approve. Issues #79 / #87 stay open.