Scikit Learn Multilabel Classification: ValueError: You appear to be using a legacy multi-label data representation

前端 未结 1 1866
忘掉有多难
忘掉有多难 2021-02-07 06:19

i am trying to use scikit learn 0.17 with anaconda 2.7 for a multilabel classification problem. here is my code

import pandas as pd
import pickle
import re
from          


        
1条回答
  •  借酒劲吻你
    2021-02-07 06:38

    The documents give this example:

    >>> from sklearn.preprocessing import MultiLabelBinarizer
    >>> y = [[2, 3, 4], [2], [0, 1, 3], [0, 1, 2, 3, 4], [0, 1, 2]]
    >>> MultiLabelBinarizer().fit_transform(y)
    array([[0, 0, 1, 1, 1],
           [0, 0, 1, 0, 0],
           [1, 1, 0, 1, 0],
           [1, 1, 1, 1, 1],
           [1, 1, 1, 0, 0]])
    

    MultiLabelBinarizer.fit_transform takes in your labeled sets and can output the binary array. The output should then be alright to pass to your fit function.

    0 讨论(0)
提交回复
热议问题