I am looking for a model, a sort of onehotencoding, that could mix columns of the same category in a single vector.
[5,8,1,3]
[0,1,0,1,0,1,0,0,1,0,0,0]
with an arbitrary size set at 12.
I looked at bagofword but I did not find how to set the vector size independently of the input data.
If somebody can gives me some clues, it will be find.
Note that Bag-of-words models are used when dealing with text
. For this simpler task you can just use np.bincount
and specify a minlength
:
l = [5,8,1,3]
np.bincount(l, minlength=12)
# array([0., 1., 0., 1., 0., 1., 0., 0., 1., 0., 0., 0.])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With