import numpy as np
from keras.utils import np_utils
nsample = 100
sample_space = ["HOME","DRAW","AWAY"]
array = np.random.choice(sample_space, nsample, )
uniques, coded_id = np.unique(array, return_inverse=True)
coded_array = np_utils.to_categorical(coded_id)
Example
Input
['AWAY', 'HOME', 'DRAW', 'AWAY', ...]
Output coded_array
[[ 0. 1. 0.]
[ 0. 0. 1.]
[ 0. 0. 1.]
...,
[ 0. 0. 1.]
[ 0. 0. 1.]
[ 1. 0. 0.]]
How to reverse process and get the original data from coded_array?