8000 PERF Skip check_finite with scipy.linalg in sklearn.covariance (#18848) · franslarsson/scikit-learn@a8b1905 · GitHub
[go: up one dir, main page]

Skip to content

Commit a8b1905

Browse files
authored
PERF Skip check_finite with scipy.linalg in sklearn.covariance (scikit-learn#18848)
When check_array is run on input, use check_finite=False with scipy.linalg to avoid duplicate checks.
1 parent fa5f1d5 commit a8b1905

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

sklearn/covariance/_empirical_covariance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _set_covariance(self, covariance):
167167
self.covariance_ = covariance
168168
# set precision
169169
if self.store_precision:
170-
self.precision_ = linalg.pinvh(covariance)
170+
self.precision_ = linalg.pinvh(covariance, check_finite=False)
171171
else:
172172
self.precision_ = None
173173

@@ -182,7 +182,7 @@ def get_precision(self):
182182
if self.store_precision:
183183
precision = self.precision_
184184
else:
185-
precision = linalg.pinvh(self.covariance_)
185+
precision = linalg.pinvh(self.covariance_, check_finite=False)
186186
return precisi 8000 on
187187

188188
def fit(self, X, y=None):

sklearn/covariance/_robust_covariance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def select_candidates(X, n_support, n_trials, select=1, n_iter=30,
228228
(2 is enough to be close to the final solution. "Never" exceeds 20).
229229
This parameter must be a strictly positive integer.
230230
231-
verbose : bool, default False
231+
verbose : bool, default=False
232232
Control the output verbosity.
233233
234234
cov_computation_method : callable, \

sklearn/covariance/_shrunk_covariance.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def ledoit_wolf_shrinkage(X, assume_centered=False, block_size=1000):
176176
If False, data will be centered before computation.
177177
178178
block_size : int, default=1000
179-
Size of the blocks into which the covariance matrix will be split.
179+
Size of blocks into which the covariance matrix will be split.
180180
181181
Returns
182182
-------
@@ -271,7 +271,7 @@ def ledoit_wolf(X, *, assume_centered=False, block_size=1000):
271271
If False, data will be centered before computation.
272272
273273
block_size : int, default=1000
274-
Size of the blocks into which the covariance matrix will be split.
274+
Size of blocks into which the covariance matrix will be split.
275275
This is purely a memory optimization and does not affect results.
276276
277277
Returns
@@ -339,7 +339,7 @@ class LedoitWolf(EmpiricalCovariance):
339339
If False (default), data will be centered before computation.
340340
341341
block_size : int, default=1000
342-
Size of the blocks into which the covariance matrix will be split
342+
Size of blocks into which the covariance matrix will be split
343343
during its Ledoit-Wolf estimation. This is purely a memory
344344
optimization and does not affect results.
345345

0 commit comments

Comments
 (0)
0