I have some JSON data to be transformed to a machine-learning friendly format. Every object in my data, which will eventually become an instance in my dataset, has the exact same fields (in this case, foo
, bar
and array
). The array
field contains a variable number of sub-objects (from 0 to 10). Each of these sub-objects has one categorical field with a massive range and some other fields which can be safely ignored. All categorical fields in these sub-objects belong to the same range.
Example (massively simplified object):
{
"foo": 1
"bar": 0.5
"array" : [
{
"categorical": "Lorem"
"other": 34
"stuff": 56
},
{
"categorical": "Ipsum"
"other": 53
"stuff": 12
},
{
"categorical": "Dolore"
"other": 6
"stuff": 101
}
]
}
Obviously foo
and bar
are easily represented as numeric attributes. I would now like to represent this array (array
) as one large one-hot (or several-hot) vector. Assuming I don't care about any other field of the sub-objects except for the category field categorical
, here is my question:
Question
Is it valid and possible to set more than one bit in a one-hot vector (which would make it, I assume, a several-hot vector) to represent all categories present in this instance? If not, how could it be done?