Skip to content

MAINT Clean deprecation for 1.2: default random_state in randomized_svd #24661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions sklearn/utils/extmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def randomized_svd(
power_iteration_normalizer="auto",
transpose="auto",
flip_sign=True,
random_state="warn",
random_state=None,
svd_lapack_driver="gesdd",
):
"""Compute a truncated randomized SVD.
Expand Down Expand Up @@ -344,10 +344,7 @@ def randomized_svd(
function calls. See :term:`Glossary <random_state>`.

.. versionchanged:: 1.2
The previous behavior (`random_state=0`) is deprecated, and
from v1.2 the default value will be `random_state=None`. Set
the value of `random_state` explicitly to suppress the deprecation
warning.
The default value changed from 0 to None.

svd_lapack_driver : {"gesdd", "gesvd"}, default="gesdd"
Whether to use the more efficient divide-and-conquer approach
Expand Down Expand Up @@ -409,19 +406,6 @@ def randomized_svd(
sparse.SparseEfficiencyWarning,
)

if random_state == "warn":
warnings.warn(
"If 'random_state' is not supplied, the current default "
"is to use 0 as a fixed seed. This will change to "
"None in version 1.2 leading to non-deterministic results "
"that better reflect nature of the randomized_svd solver. "
"If you want to silence this warning, set 'random_state' "
"to an integer seed or to None explicitly depending "
"if you want your code to be deterministic or not.",
FutureWarning,
)
random_state = 0

random_state = check_random_state(random_state)
n_random = n_components + n_oversamples
n_samples, n_features = M.shape
Expand Down