You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect random_state description in RANSACRegressor documentation #34992
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.
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.
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.
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).
Activity
megandas commentedon Sep 21, 2026
Hi! I'd like to work on this documentation issue and submit a PR updating the
random_statedescription forRANSACRegressor.AnneBeyer commentedon Sep 22, 2026
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
RandomStateinstance fromcheck_random_stateis used insample_without_replacement, but also passed to theestimatorif 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 theRandomStateinstance.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.
AnneBeyer commentedon Sep 22, 2026
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).
Kaustav5505g commentedon Sep 30, 2026
Hi there, assigning this to myself—will submit a PR shortly.
AryaTopale commentedon Sep 30, 2026
Hi, I have already submitted a PR for this