8000 CI Fixes test_rank_deficient_design (#21345) · scikit-learn/scikit-learn@810098b · GitHub
[go: up one dir, main page]

Skip to content

Commit 810098b

Browse files
thomasjpfanogrisel
authored andcommitted
CI Fixes test_rank_deficient_design (#21345)
Co-authored-by: Olivier Grisel <olivier.grisel@gmail.com>
1 parent cc60f9a commit 810098b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

doc/whats_new/v1.0.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Fixed models
4343
between sparse and dense input. :pr:`21195`
4444
by :user:`Jérémie du Boisberranger <jeremiedbb>`.
4545

46+
:mod:`sklearn.linear_model`
47+
...........................
48+
49+
- |Fix| Improves stability of :class:`linear_model.LassoLars` for different
50+
versions of openblas. :pr:`21340` by `Thomas Fan`_.
51+
4652
:mod:`sklearn.neighbors`
4753
........................
4854

@@ -677,7 +683,7 @@ Changelog
677683
Dupre la Tour`_.
678684

679685
- |Fix| Decrease the numerical default tolerance in the lobpcg call
680-
in :func:`manifold.spectral_embedding` to prevent numerical instability.
686+
in :func:`manifold.spectral_embedding` to prevent numerical instability.
681687
:pr:`21194` by :user:`Andrew Knyazev <lobpcg>`.
682688

683689
:mod:`sklearn.metrics`

sklearn/linear_model/_least_angle.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ def _lars_path_solver(
544544
sys.stdout.flush()
545545

546546
tiny32 = np.finfo(np.float32).tiny # to avoid division by 0 warning
547+
cov_precision = np.finfo(Cov.dtype).precision
547548
equality_tolerance = np.finfo(np.float32).eps
548549

549550
if Gram is not None:
@@ -726,6 +727,10 @@ def _lars_path_solver(
726727
# orthogonal (QR) decomposition of X
727728
corr_eq_dir = np.dot(Gram[:n_active, n_active:].T, least_squares)
728729

730+
# Explicit rounding can be necessary to avoid `np.argmax(Cov)` yielding
731+
# unstable results because of rounding errors.
732+
np.around(corr_eq_dir, decimals=cov_precision, out=corr_eq_dir)
733+
729734
g1 = arrayfuncs.min_pos((C - Cov) / (AA - corr_eq_dir + tiny32))
730735
if positive:
731736
gamma_ = min(g1, C / AA)

0 commit comments

Comments
 (0)
0