Skip to content

Imputer(with add_indicator_features=True) can create arrays of different shape in transform() than in fit_transform() #6767

@mfeurer

Description

@mfeurer
from sklearn.preprocessing import Imputer
import numpy as np

X_train = np.array([[1, np.NaN], [1, 1]])
X_test = np.array([[1, 1], [1, 1]])

imputer = Imputer(add_indicator_features=True)
X_train_imp = imputer.fit_transform(X_train)
print(X_train_imp.shape)

X_test_imp = imputer.transform(X_test)
print(X_test_imp.shape)

Expected Results

(2, 3)
(2, 3)

Actual Results

(2, 3)
(2, 2)

Versions

Linux-3.13.0-54-generic-x86_64-with-Ubuntu-14.04-trusty
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4]
NumPy 1.11.0
SciPy 0.17.0
Scikit-Learn 0.18.dev0

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEasyWell-defined and straightforward way to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions