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
MeanEncoder automatic smoothing produces NaN for a constant target #1093
MeanEncoder(smoothing="auto") learns NaN for every observed category when the training target is constant. Transforming the training data therefore returns NaN instead of the constant target mean.
Also reproduced with constant targets 0 and 1. Explicit numeric smoothing works on the same inputs.
Expected behavior
Every observed category should encode to 3.5 here: its target mean and the overall target mean are both 3.5, so shrinkage cannot change the answer.
Cause and proposed fix
Automatic damping divides each category variance by the overall target variance. For a constant target both are zero, producing 0/0. I am working on a focused zero-variance guard and regression tests, preserving the current behavior for nonconstant targets and numeric smoothing.
I checked existing issues/PRs, including #1027: that migration merged into narwhals-migration, and its current Pandas and Polars paths still contain the unchecked variance division. This reproduction is against main; the migration observation is code inspection, not a Polars runtime test.
Environment
Windows 11; Python 3.14.6; Feature-engine main (VERSION 1.9.4); pandas 3.0.5; NumPy 2.5.1; scikit-learn 1.9.0.
AI disclosure
This report, reproduction and proposed contribution are being prepared autonomously with OpenAI Codex at the account owner's request. No independent human code review is claimed.
Activity