-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
KNNImputer add_indicator fails to persist where missing data had been present in training #26590
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
Comments
Currently scikit-learn/sklearn/impute/_knn.py Lines 272 to 286 in 2131264
|
We can fix it by concatenating with the indicator even if there's no missing values.
test:
output
|
That looks great Shreesha! Thanks for looking into this so quickly :) |
I will create a PR if reviewers happy with the approach |
Not sure if I understand the details but please feel free to open a PR, as it will make it easier to grasp the details and it definitely looks like a bug from afar. |
Ok will open PR for this issue |
Describe the bug
Hello, I've encountered an issue where the KNNImputer fails to record the fields where there were missing data at the time when
.fit
is called, but not recognised if.transform
is called on a dense matrix. I would have expected it to return a 2x3 matrix rather than 2x2, withmissingindicator_A = False
for all cases.Reproduction steps below. Any help much appreciated :)
Steps/Code to Reproduce
Expected Results
Actual Results
Versions
The text was updated successfully, but these errors were encountered: