ENH TransformedTargetRegressor.fit() raises if only inverse_func is provided - #28483
thomasjpfan merged 3 commits into
Conversation
TransformedTargetRegressor.fit() raises if only inverse_func is providedTransformedTargetRegressor.fit() raises if only inverse_func is provided
jeremiedbb
left a comment
There was a problem hiding this comment.
Thanks for the PR @StefanieSenger.
Currently when inverse_func is passed and func is left to None, func falls back to identity and we get a warning because both functions are not their respective inverse.
I agree that falling back to identity when inverse_func is passed is not a desirable behavior so I'm +1 to raise an error. Since it's a change of behavior, it requires an entry in the change log though.
| if (self.func is not None and self.inverse_func is None) or ( | ||
| self.inverse_func is not None and self.func is None | ||
| ): |
There was a problem hiding this comment.
You can simplify this condition but I'm not sure it helps readability so feel free to ignore :)
| if (self.func is not None and self.inverse_func is None) or ( | |
| self.inverse_func is not None and self.func is None | |
| ): | |
| if (self.func is not None) == (self.inverse_func is None): |
There was a problem hiding this comment.
I think that this is difficult to read and would prefer to keep the other code, if that's okay.
|
Thanks @jeremiedbb, I should have explained it the way you did. |
|
Please also add a what's new entry |
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
|
I've applied your suggestions, @thomasjpfan and added the changelog entry, @jeremiedbb. |
TransformedTargetRegressor.fit() raises if only inverse_func is providedTransformedTargetRegressor.fit() raises if only inverse_func is provided
What does this implement/fix? Explain your changes.
This PR suggests to raise an error if users only provide
inverse_functoTransformedTargetRegressor()without explicitely settingfuncas well.It's losely connected to #28480, where I came across this issue.
Not sure if I should add a changelog entry here.