You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
YeoJohnsonTransformer inverse_transform loses small nonzero values #1100
Describe the bug YeoJohnsonTransformer.inverse_transform loses nonzero values near zero through cancellation in the inverse formulas. This reproduces on Feature-engine 1.9.4 and main d866312874a66364c6dee3c247e69476b478395c.
The output is [-1e-20, 0.0, 1e-20] followed by [0.0, 0.0, 0.0]. The fitted lambda is approximately 1; no fitted attribute needs to be overridden. Normal-sized values such as [-1.0, 0.0, 1.0] round-trip correctly.
Expected behavior
The inverse should recover the nonzero values with relative accuracy, as the forward transformation does. The 1 + x and subtraction of 1 in the inverse formulas round away these values.
Additional context
I am working on a small fix using log1p and expm1 for the mathematically equivalent inverse formulas, with near-zero round-trip regressions and normal-sized controls. This retains the inverse behavior introduced in #679/#696 and the index correction in #794. The open narwhals migration #965 retains the current cancellation-prone formulas, so this is a separate numerical correction.
Activity