@@ -274,7 +274,7 @@ def randomized_svd(
274
274
random_state = "warn" ,
275
275
svd_lapack_driver = "gesdd" ,
276
276
):
277
- """Computes a truncated randomized SVD.
277
+ """Compute a truncated randomized SVD.
278
278
279
279
This method solves the fixed-rank approximation problem described in [1]_
280
280
(problem (1.5), p5).
@@ -357,6 +357,15 @@ def randomized_svd(
357
357
358
358
.. versionadded:: 1.2
359
359
360
+ Returns
361
+ -------
362
+ u : ndarray of shape (n_samples, n_components)
363
+ Unitary matrix having left singular vectors with signs flipped as columns.
364
+ s : ndarray of shape (n_components,)
365
+ The singular values, sorted in non-increasing order.
366
+ vh : ndarray of shape (n_components, n_features)
367
+ Unitary matrix having right singular vectors with signs flipped as rows.
368
+
360
369
Notes
361
370
-----
362
371
This algorithm finds a (usually very good) approximate truncated
@@ -381,6 +390,17 @@ def randomized_svd(
381
390
382
391
.. [3] An implementation of a randomized algorithm for principal component
383
392
analysis A. Szlam et al. 2014
393
+
394
+ Examples
395
+ --------
396
+ >>> import numpy as np
397
+ >>> from sklearn.utils.extmath import randomized_svd
398
+ >>> a = np.array([[1, 2, 3, 5],
399
+ ... [3, 4, 5, 6],
400
+ ... [7, 8, 9, 10]])
401
+ >>> U, s, Vh = randomized_svd(a, n_components=2, random_state=0)
402
+ >>> U.shape, s.shape, Vh.shape
403
+ ((3, 2), (2,), (2, 4))
384
404
"""
385
405
if isinstance (M , (sparse .lil_matrix , sparse .dok_matrix )):
386
406
warnings .warn (
0 commit comments