one hot encoding
a guest May 17th, 2018 130 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- def one_hot_encode(y):
- encoded = np.zeros((y.shape, 3))
- for i, l in enumerate(y):
- encoded[i, l] = 1.
- return encoded
- encoded = one_hot_encode(labels)
- print(encoded[[0, 51, 101]])
RAW Paste Data