[MRG+1] Fix/pipeline param error msg#13536
[MRG+1] Fix/pipeline param error msg#13536NicolasHug merged 24 commits intoscikit-learn:masterfrom okz12:fix/pipeline_param_error_msg
Conversation
jnothman
left a comment
There was a problem hiding this comment.
Please add a test to test_pipeline.py. I'm pretty sure this does not fix the issue
|
I added this test case that catches the error: |
|
The problem I'm concerned with is pipe.fit(X, y, sample_weight=weight)
|
|
@okz12 as described in the original issue #13534 (comment) the problem we are trying to address here is that if a user passes pipe.fit([[0], [0]], [0, 1], sample_weight=[1, 1])they end up with an error message that is not clear at all (Not enough values to unpack...). We want this error message to become something along the lines of |
|
I've added the error message and an accompanying test. I am checking on whether two underscores '__' are within the variable name, and this would catch other parameters besides sample_weight. I made the error generic referring to parameters rather than sample_weight in particular but kept the sample_weight parameter passing example. Let me know if this should be changed. |
NicolasHug
left a comment
There was a problem hiding this comment.
Minor comments but LGTM otherwise
|
Also you might want to change the title to [MRG] |
|
Not sure if we need to worry about changing a ValueError into a TypeError. |
|
Or actually, whether we must be consistent and also raise a TypeError in the case of any other parameter names (including |
|
I found examples in gaussian_process/kernels.py and base.py where it splits on '__' and raises a ValueError if the parameter name is invalid. Not sure if I should change pipeline.py to ValueError or the other two to TypeError. |
|
Hm, I guess the most consistent way would be to raise a We raise |
|
Okay let's be backwards compatible and keep with ValueError.
|
|
Changing to ValueError breaks the test for fix #13472. The error message picked up is from my fix rather than the fix in #13472, which causes the error message to mismatch and the test-case to fail. I'm not entirely sure of the implications of this. Is it good that this fix captures both errors, in which case I can update the test case for gradient boosting. Test Case for #13472: Output Error: |
|
Yes, IMO, change the gradient boosting check to conform to this. |
|
You need to not modify the gradient boosting test, but the gradient boosting code, to check for the right pipeline failure error message here: |
|
Merged, thanks @okz12 ! |
This reverts commit c79e34b.
This reverts commit c79e34b.
Reference Issues/PRs
Fixes #13534
What does this implement/fix? Explain your changes.
The error message for passing a sample_weight is unclear. A check has been introduced for when the step name is not found in the fit_params_steps that raises a TypeError.
Any other comments?