'How to covert labels array into one vector of letters
I have the labels as the following:
array([[1., 0., 0., 0.], [1., 0., 0., 0.], [1., 0., 0., 0.], ..., [1., 0., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]], dtype=float32)
How can I turn this into one vector that has for example a letter representing each class [a, a, a, b, c, d]
Solution 1:[1]
You can use np.argmax() with map():
list(map(lambda x: chr(ord('a') + x), np.argmax(arr, axis=1)))
This outputs:
['a', 'a', 'a', 'a', 'c', 'd']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BrokenBenchmark |
