-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Added sample_weight parameter to ransac.fit #6140
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
[MRG+1] Added sample_weight parameter to ransac.fit #6140
Conversation
Please make sure no-one else is working on it, before issuing a pull request next time. |
@@ -243,6 +244,17 @@ def fit(self, X, y): | |||
except ValueError: | |||
pass | |||
|
|||
fit_parameters = signature(base_estimator.fit).parameters | |||
estimator_name = type(base_estimator).__name__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reuse has_fit_parameter
from sklearn.utils.validation
Can you add a test, testing this new feature? |
…d raise an exception when sample_weight is passed to base_estimators that dont support it.
Thanks for the feedback @MechCoder , |
@@ -195,6 +195,10 @@ def fit(self, X, y): | |||
`is_data_valid` and `is_model_valid` return False for all | |||
`max_trials` randomly chosen sub-samples. | |||
|
|||
TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should document sample_weight
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can you remove this block and document it under sample_weight
?, i.e
sample_weight: array-like,
blah, blah.. raises Error if balh blah
I have modified the tests as you suggested , they all passed. I'm still not sure about considering sample_weight when sampling ie subset_idxs |
@@ -188,6 +188,10 @@ def fit(self, X, y): | |||
y : array-like, shape = [n_samples] or [n_samples, n_targets] | |||
Target values. | |||
|
|||
sample_weight: numpy array of shape [n_samples] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numpy array
-> array-like
Also indent the next line just 4 spaces to the first line.
Look at how all the other parameters are documented
@imaculate please run pep8 on both the files. (just the above cosmetic comments and that's it from me) |
Thanks .. Done! |
|
||
assert_almost_equal(ransac_estimator.estimator_.coef_, ref_coef_) | ||
|
||
""" check that if base_estimator.fit doesn't support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just make this a comment starting with #
Done. |
LGTM. Well Done. |
Merged as 41526cb (after updating whatsnew). Thanks 🍻 🍷 !! |
Thanks @MechCoder @ahojnnes .First contribution! 🍻 . |
🍻 :) |
Resolved issue #6113 and #5871.
For estimators that used sample_weight parameter in the fit method, it was requested that similar should be applied to ransacRegressor. This has been intergrated.