-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
RANSAC does not pass sample weights to final estimator #13425
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
Comments
Thanks for the report. A fix is welcome |
Desperately waiting for first time issues tag XD |
You're welcome to take it on as a first time contributor. My main reason for not adding that tag is that this may not be trivial to write a test for. |
@jnothman, if no one is looking into this, would you mind clarifying the kind of tests necessary here? Do we want to assert that calls to Or would it be sufficient to give |
I think the latter should be fine
|
It is not enough to pass sample_weight to base_estimator.fit(), because it is the loss_function within RANSACRegressor.fit() who determined whether the weighted inlier_subset is good enough. Sample_weight should be passed to loss_function as well. |
@jnothman, this class has been made private, is this issue still open though? |
As in should it really still be open? |
It passes pytest test_ransac.py, by the way. No errors. Inside that test file, there are weights passed to the fit method of RANSACRegressor. I did a couple tests where I edited RANSACRegressor to make it fail, but the code I posted works. |
The class is not private. It is publicly available for import from |
Oh, first time dealing with private anything in Python, actually. Thanks for letting me know. |
I thought since it was in a private file, maybe it was. Do you think I need to change my code at all? |
If you have code, please submit a pull request for review. I agree with @pallashadow that it looks like the loss calculation should also be weighted... but we ideally drive this from tests. See #15657 |
RANSACRegressor does not pass weights to the used estimator during the training of the final model.
Sample weights to RANSAC have been requested by #5871 and #6113, and implemented in #6140, but the weights of the final inlier sample are not used during the training of the final model.
The issue only causes crashes when using a custom estimator which always requires the sample_weight parameter to be passed to it, as is the case in the training of the final estimator with the current implementation.
scikit-learn/sklearn/linear_model/ransac.py
Lines 449 to 452 in 4140657
The text was updated successfully, but these errors were encountered: