12
12
# License: BSD 3 clause
13
13
14
14
import warnings
15
+ from numbers import Integral
15
16
16
17
import numpy as np
17
18
from scipy import linalg , sparse
18
19
20
+ from ..utils ._param_validation import Interval , StrOptions , validate_params
19
21
from . import check_random_state
20
22
from ._array_api import _is_numpy_namespace , get_namespace
21
23
from ._logistic_sigmoid import _log_logistic_sigmoid
@@ -288,6 +290,20 @@ def randomized_range_finder(
288
290
return Q
289
291
290
292
293
+ @validate_params (
294
+ {
295
+ "M" : [np .ndarray , "sparse matrix" ],
296
+ "n_components" : [Interval (Integral , 1 , None , closed = "left" )],
297
+ "n_oversamples" : [Interval (Integral , 0 , None , closed = "left" )],
298
+ "n_iter" : [Interval (Integral , 0 , None , closed = "left" ), StrOptions ({"auto" })],
299
+ "power_iteration_normalizer" : [StrOptions ({"auto" , "QR" , "LU" , "none" })],
300
+ "transpose" : ["boolean" , StrOptions ({"auto" })],
301
+ "flip_sign" : ["boolean" ],
302
+ "random_state" : ["random_state" ],
303
+ "svd_lapack_driver" : [StrOptions ({"gesdd" , "gesvd" })],
304
+ },
305
+ prefer_skip_nested_validation = True ,
306
+ )
291
307
def randomized_svd (
292
308
M ,
293
309
n_components ,
@@ -314,9 +330,9 @@ def randomized_svd(
314
330
Number of singular values and vectors to extract.
315
331
316
332
n_oversamples : int, default=10
317
- Additional number of random vectors to sample the range of M so as
333
+ Additional number of random vectors to sample the range of `M` so as
318
334
to ensure proper conditioning. The total number of random vectors
319
- used to find the range of M is n_components + n_oversamples. Smaller
335
+ used to find the range of `M` is ` n_components + n_oversamples` . Smaller
320
336
number can improve speed but can negatively impact the quality of
321
337
approximation of singular vectors and singular values. Users might wish
322
338
to increase this parameter up to `2*k - n_components` where k is the
0 commit comments