Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #470 +/- ##
==========================================
+ Coverage 76.95% 77.02% +0.07%
==========================================
Files 105 105
Lines 7612 7631 +19
==========================================
+ Hits 5858 5878 +20
+ Misses 1754 1753 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Elastic net: compute only the diagonal of the inverse for the variances
Every fit computes the variance of the parameters, which needs only the diagonal of
(XᵀX)⁻¹. It was computing the full inverse with QR, about 700 ms for 512features, often more than the solver itself.
Changes
XᵀX = L Lᵀ(Cholesky), so(XᵀX)⁻¹ = L⁻ᵀ L⁻¹and entryjis the squared normof column
jofL⁻¹.L⁻¹is built a row at a time, on contiguous rows, usingonly its lower triangle. Matches the QR result to about 1e-14 relative (new test).
blaspath (invh_into) is unchanged, except that it now keeps only thediagonal.
Behavior change
With exactly collinear features (e.g. a duplicated column),
XᵀXis singular.Before, the QR inverse returned
OkwithNaNz-scores for those features; nowCholesky fails and
z_score()/confidence_95th()returnErr(ElasticNetError::IllConditioned)(new test).Results
Fits on independent features, where the solver needs only a few passes and the
variance dominates: f64, n = 5 000, penalty 0.1. Core Ultra 7 155H, one core.
Measured with the criterion bench from #469 plus a group on independent features.
With both PRs, a 512-feature fit goes from 1119 ms to 100 ms (11×).