I am working on a multi-label text classification problem. In order to encode the labels, I am using MultiLabelBinarizer. The labels of the dataset look like - [cs.AI, cs.CL, cs.CV, cs.NE, stat.ML][cs.CL, cs.AI, cs.LG, cs.NE, stat.ML][cs.CL, cs.AI, cs.LG, cs.NE, stat.ML][stat.ML, cs.AI, cs.CL, cs.LG, cs.NE][cs.CL, cs.AI, cs.LG, cs.NE, stat.ML] When I am using mlb = MultiLabelBinarizer() mlb.fit(labels)print(mlb.classes_) It gives me - array([' ', ',', '.', 'A', 'B', 'C', 'D', 'E', 'G', 'H', 'I', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V', 'Y', '[', ']', 'a', 'c', 'h', 'm', 's', 't'], dtype=object) I (partially) fixed this problem by mlb.fit([y_train]) and I got (I printed first 10 classes) - array(['[cs.AI, cs.CC]', '[cs.AI, cs.CV]', '[cs.AI, cs.CY]', '[cs.AI, cs.DB]', '[cs.AI, cs.DS]', '[cs.AI, cs.GT]', '[cs.AI, cs.HC]', '[cs.AI, cs.IR]', '[cs.AI, cs.LG, stat.ML]', '[cs.AI, cs.LG]'], dtype=object) Ideally, it should output the individual classes (there may be something wrong in my code). When I am using mlb.fit_transform([y_train]), I am getting - array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) Help would be very much appreciated. Here's the corresponding StackOverflow issue: https://stackoverflow.com/questions/57917936/multilabelbinarizer-gives-indiv... Sayak Paul | sayak.dev
Please don't repost questions. Also, you didn't create a minimal reproducible example as suggested on stackoverflow: https://stackoverflow.com/help/minimal-reproducible-example That process would probably have shown you where the issue is. I highly recommend doing that next time. On 9/16/19 12:12 AM, Sayak Paul wrote:
I am working on a multi-label text classification problem. In order to encode the labels, I am using |MultiLabelBinarizer|. The labels of the dataset look like -
|[cs.AI,cs.CL,cs.CV,cs.NE,stat.ML][cs.CL,cs.AI,cs.LG,cs.NE,stat.ML][cs.CL,cs.AI,cs.LG,cs.NE,stat.ML][stat.ML,cs.AI,cs.CL,cs.LG,cs.NE][cs.CL,cs.AI,cs.LG,cs.NE,stat.ML]|
When I am using
|mlb =MultiLabelBinarizer()mlb.fit(labels)print(mlb.classes_)|
It gives me -
|array([' ',',','.','A','B','C','D','E','G','H','I','L','M','N','O','P','R','S','T','V','Y','[',']','a','c','h','m','s','t'],dtype=object)|
I (partially) fixed this problem by |mlb.fit([y_train])| and I got (I printed first 10 classes) -
|array(['[cs.AI, cs.CC]','[cs.AI, cs.CV]','[cs.AI, cs.CY]','[cs.AI, cs.DB]','[cs.AI, cs.DS]','[cs.AI, cs.GT]','[cs.AI, cs.HC]','[cs.AI, cs.IR]','[cs.AI, cs.LG, stat.ML]','[cs.AI, cs.LG]'],dtype=object)|
Ideally, it should output the individual classes (there may be something wrong in my code). When I am using |mlb.fit_transform([y_train])|, I am getting -
|array([[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]])|
Help would be very much appreciated.
Here's the corresponding StackOverflow issue: https://stackoverflow.com/questions/57917936/multilabelbinarizer-gives-indiv...
Sayak Paul |sayak.dev <http://sayak.dev>
_______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
participants (2)
-
Andreas Mueller -
Sayak Paul