-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG] Deprecate residual_metric and add support for loss in RANSAC #5497
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
Conversation
ping @amueller On hindsight, I think something like |
Tests should fail because of this (https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/linear_model/tests/test_ransac.py#L296) . I find it odd that the residual metric for a 1-D array, expects a 2-D array. I'm not sure what the cleanest way to proceed is, except for deprecating the behavior. |
ping @ahojnnes . Would be great to have your inputs. |
test? |
I can add a test if we decide what to do with the current behavior. The current behavior for |
no opinion ... |
deprecate? |
who wrote this in the first place?
|
See: #2025 |
@ahojnnes what's your take on this?
|
@MechCoder travis is unhappy |
@@ -177,6 +183,15 @@ def __init__(self, base_estimator=None, min_samples=None, | |||
self.residual_metric = residual_metric | |||
self.random_state = random_state | |||
|
|||
def _residual_metric(residual): |
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 don't need this.
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.
I mean you don't need to make a method out of this.
Can you add tests? |
@amueller Tests are failing because I do not know what to do with the existing behavior for 1-D array. The parameter For example, now if I need to support arbitrary residual metrics for 1-D array, I need to do this
which is unusual, don't you think? |
@agramfort @arjoly IRL @MechCoder and I just discussed the current behavior. We thought it might be more scikit-learn style to pass a |
I don't use this code. Can you type usage snippets of before and after
refactoring?
|
|
thinking about it ...
in terms of semantic score is used commonly for prediction evaluation while
here it's for the fit. It's more a loss as specified in SGD. So in the end
I would not call it a score.
|
Then, how do you suggest we provide string inputs? |
you do as in SGD. Support what makes sense for 90% people ie implement just
MAE and MSE passed as full strings but also accept callables. You keep all
this in ransac file.
my 2c
|
sounds good to me as well. |
I'm happy to use callables that take |
cf3d731
to
a01d360
Compare
@amueller @agramfort I've made changes. Please review. |
that's fine with me. I'll let @amueller validate. |
@amueller I can haz reviews? |
else: | ||
residual_metric = self.residual_metric | ||
raise ValueError( | ||
"loss should be 'absolute_loss', 'squared_loss' or a callable." |
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.
Missing space in the string at the end. Capitalize "Got".
Left you two comments, otherwise LGTM. |
a01d360
to
be70e65
Compare
be70e65
to
761b1f7
Compare
Two +1's from @agramfort and @ahojnnes . Will merge when Travis passes |
[MRG] Deprecate residual_metric and add support for loss in RANSAC
Partly fixes #4740
Supply arbitrary residual metrics for 1-D targets was not possible.
The workaround was to explicitly define res_met as accepting 2-D arrays, (since there is a reshape done) which is non-obvious.