Skip to content

DOC clarify RANSACRegressor random_state behavior - #35020

Merged
lesteve merged 5 commits into
scikit-learn:mainfrom
AryaTopale:doc-ransac-random-state
Oct 12, 2026
Merged

lesteve merged 5 commits into
scikit-learn:mainfrom
AryaTopale:doc-ransac-random-state

Conversation

@AryaTopale

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #34992

What does this implement/fix? Explain your changes.

Clarifies the documentation of RANSACRegressor.random_state to reflect its behavior in the implementation.

The same random state is used for selecting data subsets and, when supported, is passed to the underlying estimator. Consequently, random numbers consumed by the estimator can affect the data subsets selected in subsequent RANSAC iterations.

Introduce yourself

Hi! I'm Arya, a B.Tech Graduate ECE student from IIIT Hyderabad and a new contributor to scikit-learn.

I use scikit-learn for machine learning projects and wanted to contribute by improving the documentation around existing behavior.

AI usage disclosure

I used AI assistance for:

  • Documentation Understanding(including examples)
  • Research and understanding

Any other comments?

The RANSAC test suite passes locally (27 passed).

@github-actions

Copy link
Copy Markdown

Thank you for opening your first pull request to scikit-learn! 🎉

To help get your contribution reviewed, please make sure that:

  • You have filled out the pull request template.

  • The pull request addresses an existing issue that is ready for contribution (e.g. not tagged as 'Needs Triage', 'Needs Decision', ...). If you are proposing a new feature, please open an issue to discuss it first.

  • There are no other open pull requests already targeting the same issue.

  • You have followed the pull request checklist. In particular, linting and tests should pass.

@AnneBeyer AnneBeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @AryaTopale. I have one suggestion to make it clearer that the actual instance is shared (instead of passing the input to random_state, which can also be int or None), otherwise LGTM.

Comment thread sklearn/linear_model/_ransac.py Resolved
@AnneBeyer AnneBeyer added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! good first PR to review Simple atomic PR to review labels Sep 23, 2026
@AnneBeyer AnneBeyer moved this to PR waiting for reviews in Labs Sep 23, 2026
@AnneBeyer AnneBeyer added this to Labs Sep 23, 2026

@cakedev0 cakedev0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Marwan-verse

Copy link
Copy Markdown

AI-assisted source check: in RANSACRegressor.fit, check_random_state(self.random_state) resolves the RNG, and the same object is used by sample_without_replacement and passed to estimator.set_params(random_state=...) when supported. So randomness consumed by the estimator can affect later subset draws, as the proposed docstring says. The phrase “same random state instance” matches the implementation. Source.

@AnneBeyer

Copy link
Copy Markdown
Member

@AryaTopale, could you please apply my suggestion above? Then I think this is ready to be merged.

@AnneBeyer AnneBeyer removed the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 8, 2026
@AryaTopale

AryaTopale commented Oct 8, 2026 via email

Copy link
Copy Markdown
Contributor Author

@AnneBeyer

Copy link
Copy Markdown
Member

The CI hiccup looks unrelated, can you merge main again to re-trigger the CI run?

@lesteve
lesteve enabled auto-merge (squash) October 12, 2026 13:09

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved based on trusted people approvals 🙏

@lesteve

lesteve commented Oct 12, 2026

Copy link
Copy Markdown
Member

Personally I find the new wording slightly too verbose, but I don't think this really matters, and this has been waiting for a while already, so I enabled auto-merge.

@lesteve
lesteve merged commit bebaf70 into scikit-learn:main Oct 12, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation good first PR to review Simple atomic PR to review module:linear_model Quick Review For PRs that are quick to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect random_state description in RANSACRegressor documentation

5 participants