Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

one hot numpy

import numpy as np
a = np.array([1, 0, 3])
b = np.zeros((a.size, a.max()+1))
b[np.arange(a.size),a] = 1
print(b)
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #hot #numpy
ADD COMMENT
Topic
Name
8+6 =