Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed

Conversation

imaculate
Copy link
Contributor

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.

@MechCoder
Copy link
Member

Please make sure no-one else is working on it, before issuing a pull request next time.

@MechCoder MechCoder changed the title Added sample_weight parameter to ransac.fit [MRG] Added sample_weight parameter to ransac.fit Jan 8, 2016
@@ -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__
Copy link
Member

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

@MechCoder
Copy link
Member

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.
@imaculate
Copy link
Contributor Author

Thanks for the feedback @MechCoder ,
I have made more changes, Please check them out

@@ -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
Copy link
Member

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

Copy link
Member

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

@imaculate
Copy link
Contributor Author

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]
Copy link
Member

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

@MechCoder
Copy link
Member

@imaculate please run pep8 on both the files.

(just the above cosmetic comments and that's it from me)

@imaculate
Copy link
Contributor Author

Thanks .. Done!


assert_almost_equal(ransac_estimator.estimator_.coef_, ref_coef_)

""" check that if base_estimator.fit doesn't support
Copy link
Member

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 #

@MechCoder
Copy link
Member

lgtm.

cc: @TomDLT | @ahojnnes for the second review

@MechCoder MechCoder changed the title [MRG] Added sample_weight parameter to ransac.fit [MRG+1] Added sample_weight parameter to ransac.fit Jan 14, 2016
@imaculate
Copy link
Contributor Author

Done.

@ahojnnes
Copy link
Contributor

LGTM. Well Done.

@MechCoder
Copy link
Member

Merged as 41526cb (after updating whatsnew). Thanks 🍻 🍷 !!

@MechCoder MechCoder closed this Jan 14, 2016
@MechCoder
Copy link
Member

@ahojnnes Since you are now here, it would be great if you can give a second pass over #5497

@imaculate
Copy link
Contributor Author

Thanks @MechCoder @ahojnnes .First contribution! 🍻 .

@TomDLT
Copy link
Member

TomDLT commented Jan 14, 2016

🍻 :)

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

Successfully merging this pull request may close these issues.

4 participants