0
$\begingroup$

At work I often have a variable encoding where you count the number of each category with respect to a key. (Which makes sense for the domain I am in) Does this process have a machine learning or statistical name?

Recently, I realized from Encoding Categorical Features that is not exactly "one-hot encoding". For example, given this data:

+----+----------+-----+
| id | category | y   |
+----+----------+-----+
| 1  | A        | 40  |
+----+----------+-----+
| 1  | B        | 40  |
+----+----------+-----+
| 1  | C        | 40  |
+----+----------+-----+
| 2  | B        | 50  |
+----+----------+-----+
| 3  | A        | 100 |
+----+----------+-----+
| 3  | A        | 100 |
+----+----------+-----+
| 3  | C        | 100 |
+----+----------+-----+

I normally get this:

+----+---+---+---+----+
| id | A | B | C | y  |
+----+---+---+---+----+
| 1  | 1 | 1 | 1 | 40 |
+----+---+---+---+----+
| 2  | 0 | 1 | 0 | 50 |
+----+---+---+---+----+
| 3  | 2 | 0 | 1 |100 |
+----+---+---+---+----+

Which makes sense because a repeated category in this particular database is a measure severity and intensity. However, one-hotting is apparently this:

+----+---+---+---+----+
| id | A | B | C | y  |
+----+---+---+---+----+
| 1  | 1 | 1 | 1 | 40 |
+----+---+---+---+----+
| 2  | 0 | 1 | 0 | 50 |
+----+---+---+---+----+
| 3  | 1 | 0 | 1 |100 |
+----+---+---+---+----+

My question is this a common procedure and if so what is its name?

$\endgroup$
  • $\begingroup$ Sorry this is my first time, posting so I edited the example so the question make sense. The difference is in row 3 column A. $\endgroup$ – pierround Dec 17 '19 at 18:09
0
$\begingroup$

The first thing that comes to my mind is a term related to database management. If this is what you are looking for, this is generally called a pivot:

https://en.m.wikipedia.org/wiki/Pivot_table

$\endgroup$
  • $\begingroup$ Thank you, I realized I was overcomplicating things a little because in BI they have pivots and unpivots and other different names for what are essentially rotation and aggregation of data. $\endgroup$ – pierround Feb 5 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.