-
-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
Description
Validate ensure that X
is 2D as it is imposed in any other transformer. However, the output of the FunctionTransformer
can be 1D if the provided function does not ensure it.
I think that we should ensure that the output is 2D since it could be useful when chaining transformer and estimator. validate=False
will still allow for 1D in this case.
Example
import numpy as np
from sklearn.preprocessing import FunctionTransformer
def func(y):
return np.sqrt(y[:, 0] ** 2 + y[:, 1] ** 2)
transformer = FunctionTransformer(func=func, validate=True)
X = np.random.random((100, 2))
print(transformer.fit_transform(X).shape)
(100,)
Metadata
Metadata
Assignees
Labels
No labels