Pythonでone-hot表現
NumPyのeyeまたはidentityでone-hot表現に変換 | note.nkmk.me
numpy.identity
code:py
import numpy as np
a = 3, 0, 8, 1, 9
a_one_hot = np.identity(10, dtype=np.uint8)a
print(a_one_hot)
# [0 0 0 1 0 0 0 0 0 0
# 1 0 0 0 0 0 0 0 0 0
# 0 0 0 0 0 0 0 0 1 0
# 0 1 0 0 0 0 0 0 0 0
# 0 0 0 0 0 0 0 0 0 1]
sklearn.preprocessing.label_binarize()
#one-hot
#python Python.icon