Skip to content

Incorrect random_state description in RANSACRegressor documentation #34992

Closed

Description

@AryaTopale

Introduce yourself

Hi! I am new to the scikit-learn community. I am a data scientist and often use scikit-learn for my experiments. I recently used RANSACRegressor and noticed a possible documentation issue.

Describe the issue linked to the documentation

The random_state parameter is currently documented as:
The generator used to initialize the centers.
This description appears unrelated to RANSACRegressor and actually related to a clustering algorithm . In the implementation, random_state is used with sample_without_replacement to randomly select data subsets during RANSAC iterations. These subsets are then used to fit candidate models.
The issue also stays in the final sklearn documentation linked here : [ransac](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.RANSACRegressor.html.

Image

Suggest a potential alternative/fix

Suggested correction :
random_state : int, RandomState instance, default=None Controls the randomness of the data subsets selected during RANSAC iterations. Pass an int for reproducible output across multiple function calls. See :term:Glossary <random_state>.
I have tested the change locally, and the RANSAC test suite passes:
27 passed in 0.47s

I would be happy to submit a pull request for this documentation fix if the issue is valid.

Activity

  1. megandas commented on Sep 21, 2026

    @megandas

    Hi! I'd like to work on this documentation issue and submit a PR updating the random_state description for RANSACRegressor.

  2. AnneBeyer commented on Sep 22, 2026

    @AnneBeyer
    Member

    Hi @AryaTopale, thank you for pointing this out. This does indeed not match the behavior in the code, and it seems to be a bit more complicated:
    The RandomState instance from check_random_state is used in sample_without_replacement, but also passed to the estimator if it accepts a random state. In this case it will actually also overwrite the random state if one was specified for that estimator explicitly before. It also means that with the same random state, different sub-samples are selected in each iteration based on whether the estimator consumed draws (and how many) from the RandomState instance.
    I'm not sure if this is actually a problem, but it should at least be mentioned in the docstring. Feel free to open a PR for this.

  3. AnneBeyer commented on Sep 22, 2026

    @AnneBeyer
    Member

    Hi @megandas, thank you for your interest, but please note that the author has already expressed interest in submitting a PR for this. It would be of much greater value to the project (and even more appreciated by the maintainers) if you instead helped with investigating the reported issues and contributed to the discussion (see my comment above for an example).

  4. removed
    Needs Triage
    on Sep 22, 2026
  5. Kaustav5505g commented on Sep 30, 2026

    @Kaustav5505g

    Hi there, assigning this to myself—will submit a PR shortly.

  6. AryaTopale commented on Sep 30, 2026

    @AryaTopale
    ContributorAuthor

    Hi there, assigning this to myself—will submit a PR shortly.

    Hi, I have already submitted a PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions