I'm using sklearn's OneHotEncoder, but want to untransform my data. any idea how to do that?
>>> from sklearn.preprocessing import OneHotEncoder
>>> enc = OneHotEncoder()
>>> enc.fit([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])
>>> enc.n_values_
array([2, 3, 4])
>>> enc.feature_indices_
array([0, 2, 5, 9])
>>> enc.transform([[0, 1, 1]]).toarray()
array([[ 1., 0., 0., 1., 0., 0., 1., 0., 0.]])
but I want to be able to do the following:
>>> enc.untransform(array([[ 1., 0., 0., 1., 0., 0., 1., 0., 0.]]))
[[0, 1, 1]]
How would I go about doing this?
For context, I've built a neural network that learns the one-hot encoding space, and want to now use the nn to make real predictions that need to be in the original data format.