-
-
Notifications
You must be signed in to change notification settings - Fork 26.4k
ENH TransformedTargetRegressor.fit() raises if only inverse_func is provided
#28483
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
ENH TransformedTargetRegressor.fit() raises if only inverse_func is provided
#28483
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
thomasjpfan
left a comment
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.
Two nits, otherwise LGTM
|
Please also add a what's new entry |
Co-authored-by: Thomas J. Fan <[email protected]>
|
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.