-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Closed
Closed
Copy link
Labels
Description
Describe the bug
The mask is set to all True, so that the iterative imputation will be skipped.
scikit-learn/sklearn/impute/_iterative.py
Lines 649 to 651 in a4ebe19
# mark empty features as not missing and keep the original | |
# imputation | |
mask_missing_values[:, valid_mask] = True |
Steps/Code to Reproduce
import numpy as np
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
imp = IterativeImputer(keep_empty_features=True)
X = [[np.nan, 0, 1], [2, np.nan, 3], [4, 5, np.nan]]
print(imp.fit_transform(X))
print(imp.imputation_sequence_)
Expected Results
Should act the same as keep_empty_features=False
Actual Results
# transformed X
[[3. 0. 1. ]
[2. 2.5 3. ]
[4. 5. 2. ]]
# imputation_sequence_
[]
Versions
System:
python: 3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:38:11) [Clang 14.0.6 ]
executable: /Users/xxf/miniconda3/envs/sklearn-env/bin/python
machine: macOS-14.5-arm64-arm-64bit
Python dependencies:
sklearn: 1.6.dev0
pip: 23.2.1
setuptools: 68.0.0
numpy: 1.26.4
scipy: 1.13.0
Cython: 3.0.8
pandas: 2.1.0
matplotlib: 3.7.2
joblib: 1.3.0
threadpoolctl: 3.5.0
Built with OpenMP: True
threadpoolctl info:
user_api: blas
internal_api: openblas
num_threads: 8
prefix: libopenblas
filepath: /Users/xxf/miniconda3/envs/sklearn-env/lib/libopenblas.0.dylib
version: 0.3.23
threading_layer: openmp
architecture: VORTEX
user_api: openmp
internal_api: openmp
num_threads: 8
prefix: libomp
filepath: /Users/xxf/miniconda3/envs/sklearn-env/lib/libomp.dylib
version: None