mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-09 18:50:34 -05:00
New Post
This commit is contained in:
parent
f3d1c25d3b
commit
e63bbffaac
1 changed files with 22 additions and 0 deletions
22
content/blog/reverseonehotencode.md
Normal file
22
content/blog/reverseonehotencode.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
title: "Reverse One-Hot Encode"
|
||||
date: 2020-10-11T21:58:47-04:00
|
||||
draft: false
|
||||
tags: []
|
||||
---
|
||||
|
||||
Let's say that you have a dataset that is one hot encoded like the following observation:
|
||||
|
||||
```python
|
||||
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.
|
||||
|
||||
```python
|
||||
reverse_encoding = np.argmax(obs)
|
||||
# 13
|
||||
```
|
||||
|
Loading…
Reference in a new issue