refactor(quant): unify Ledoit-Wolf onto one impl (LV1-AE.a)#95
Merged
Conversation
The lib hosted two Ledoit-Wolf shrinkage estimators: the numpy hand-rolled quant.factor_risk.ledoit_wolf_cov (Option B) and sklearn LedoitWolf inside quant.factor_risk_xs.estimate_factor_covariance (Option A). Validated they are numerically identical (max abs diff ~1e-21 across n∈[35,1000]; both center + estimate the same shrinkage intensity toward scaled identity). So the xs ledoit_wolf branch now calls the shared numpy ledoit_wolf_cov — one LW impl in the lib. sklearn stays a lazy import for the OAS branch only. Zero numerics change (the persisted predictor F is identical to ~1e-21; no live consumer of F anyway — C.3 solve is gated). Closes audit finding #2. - 0.50.0 -> 0.51.0; +1 consolidation-contract test; suite 1107. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
LV1-AE.a — kills the duplicate Ledoit-Wolf reimplementation (audit finding #2). The lib hosted two: the numpy
quant.factor_risk.ledoit_wolf_cov(Option B) and sklearnLedoitWolfinsidequant.factor_risk_xs.estimate_factor_covariance(Option A).Validated numerically identical — max abs diff ~1e-21 across n∈[35,1000] (both center the data + estimate the same shrinkage intensity toward a scaled-identity target). So the
factor_risk_xsledoit_wolfbranch now calls the shared numpyledoit_wolf_cov— one LW impl in the lib. sklearn stays a lazy import for the OAS branch only.Risk
Zero numerics change. The predictor's persisted F is identical to ~1e-21, and there's no live consumer of F anyway (the C.3
solve_target_weightsread is gated). Predictor adopts on its next lib-pin bump; no forced re-pin.Changes
factor_risk_xs.estimate_factor_covariance:ledoit_wolf→ shared numpy impl.🤖 Generated with Claude Code