scikit-learn / scikit-learn/scikit-learn

Using `rng=` keyword argument for NumPy randomness

Open
#29,315 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API Needs Decision RFC
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

In SPEC7 https://github.com/scientific-python/specs/pull/180, has two goals:

  1. Deprecate the use of RandomState and np.random.seed
  2. Standardize the usage of rng for setting seeding.

For 1, according to NEP19, I do not think NumPy wants to deprecate np.random.seed because they see valid use cases.

For 2, the primary reason around using rng instead of random_state is that it is a "better name" for NumPy's Random Generator. I am okay with keeping random_state and not have users go the pain of changing their code.

Currently, scikit-learn does not support generators because we tied it to https://github.com/scikit-learn/enhancement_proposals/pull/88. We wanted to use generators to cleanly switch to a different RNG behavior compared to RandomState. For me, I think they can be decoupled. If we tackle https://github.com/scikit-learn/enhancement_proposals/pull/88, we can fix it for both RandomState and Generators.

@scikit-learn/core-devs What do you think of SPEC7's proposal?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading SPEC7, NEP19, and enhancement proposal 88, then review the seven comments for the unresolved position on RandomState, np.random.seed, and Generator support. The issue is complete only after the API direction and required scope are agreed; it does not identify files or tests to change.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.