-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Letting OneHotEncoder encode y? #5930
Copy link
Copy link
Closed
Labels
DocumentationEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve
Description
I think the original use case for OneHotEncoders were to encode features, but it would be nice if they were able to encode y's as well. The current functionality is as follows:
>>> from sklearn.preprocessing import OneHotEncoder
>>> y = [0, 1, 1, 0]
>>> transformed = OneHotEncoder().fit_transform(y).toarray()
/usr/local/lib/python2.7/site-packages/sklearn/utils/validation.py:386: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
DeprecationWarning)
>>> transformed
array([[ 1., 1., 1., 1.]])
Right now it's interpreting y as a single sample; the desired behavior is by letting y = np.array([0, 1, 1, 0]).reshape(-1, 1), and then running the OneHotEncoder.
What do you guys think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DocumentationEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve