Skip to content

Instantly share code, notes, and snippets.

@staricon12
Created July 13, 2021 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save staricon12/8226792d36194c2293bf39eb4ae53c3e to your computer and use it in GitHub Desktop.
Save staricon12/8226792d36194c2293bf39eb4ae53c3e to your computer and use it in GitHub Desktop.
#One hot encode
from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder()
y = ohe.fit_transform(y).toarray()
print('One hot encoded array:')
print(y[0:5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment