# How to handle multi-label feature for binary classification problem?

I have dataset like :

   profile     category  target
0        1      [5, 10]       1
1        2          [1]       0
2        3   [23, 5000]       1
3        4  [700, 4500]       0


How to handle category feature, this table may have others additional features too. One hot encoding lead to consume too much space.because number of rows is around 10 million. Any suggestion would be helpful.

I recommend using scikit-learn's MultiLabelBinarizer to encode your category feature. This is the multi-label analog of one-hot encoding, but it has a sparse_output mode, which should solve your problem of limited memory.

• This dataset also have other numerical and categorical features. how can i combine those sparse and non sparse feature together for machine learning modeling. – GIRISH kuniyal Nov 21 '19 at 4:47
• I solved sparse vs non sparse dataset combining problem by making non-sparse feature to sparse then combine both sparse feature matrix using scipy.sparse.hstack() – GIRISH kuniyal Nov 22 '19 at 7:20

MultiLabelBinarizer is an good choice. For sparse features i would say first do some feature engineering on them. If necessary then keep them else discard them. If you keep them then by applying error reduction methods helps a lot. They will fill the sparse features & then by encoding the categorical features you can apply machine learning models on them.

I was stuck on features with more sparse values so i followed the above approach. Worked fine with me.