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
Yeo-Johnson inverse_transform fails silently on extreme skew data #28946
Comments
Thanks for the report and the analysis. I confirm I can reproduce on I think that calling Not sure if it would be helpful to raise such a warning at |
I think that a warning in
Short circuiting means the EDIT: hopefully with better variable names than |
Describe the bug
The Yeo-Johnson is not a surjective transformation for negative lambdas. Therefore, the inverse transformation returns
np.nan
when inverse transforming values outside the range of the transform. This failure is silent, so it took me quite a while of debugging to understand this behavior.The problematic lines are
scikit-learn/sklearn/preprocessing/_data.py
Line 3390 in 8721245
and
scikit-learn/sklearn/preprocessing/_data.py
Line 3386 in 8721245
in which we might compute
np.power(something_negative, not_integral_value)
, which of course returnsnp.nan
as per https://numpy.org/doc/stable/reference/generated/numpy.power.htmlSteps/Code to Reproduce
To reproduce for positive values (there is a similar problem for negative values):
Expected Results
The code should either:
Actual Results
It just prints
Versions
The text was updated successfully, but these errors were encountered: