mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-22 16:26:28 -05:00
501 B
501 B
title | date | draft | tags | medium_enabled | |
---|---|---|---|---|---|
Reverse One-Hot Encode | 2020-10-11T21:58:47-04:00 | false |
|
true |
Let's say that you have a dataset that is one hot encoded like the following observation:
import numpy as np
obs = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0])
The easiest way to reverse one-hot encode the structure, is to take the argmax
of the observation.
reverse_encoding = np.argmax(obs)
# 13