daily pastebin goal
68%
SHARE
TWEET

one hot encoding

a guest May 17th, 2018 134 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def one_hot_encode(y):
  2.     encoded = np.zeros((y.shape[0], 3))
  3.    
  4.     for i, l in enumerate(y):
  5.         encoded[i, l] = 1.
  6.        
  7.     return encoded
  8.  
  9. encoded = one_hot_encode(labels)
  10. print(encoded[[0, 51, 101]])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top