ValueError('You appear to be using a legacy multi-label data'

xiaoxiao2021-02-28  107

使用sklearn时,遇到该问题,可能是因为scikit-learn版本过旧或者太新

pip install -U scikit-learn==0.16.1 就能解决

当然在0.17之后,已经不允许直接使用多类标分类

Direct support for sequence of sequences multilabel representation will be unavailable from version 0.17

而使用sklearn.preprocessing.MultiLabelBinarizer to convert to a label indicator representation.

例如

from sklearn.preprocessing import MultiLabelBinarizer

y_train = MultiLabelBinarizer().fit_transform(y_train)

y_test = MultiLabelBinarizer().fit_transform(y_test)

preds = MultiLabelBinarizer().fit_transform(preds)

转载请注明原文地址: https://www.6miu.com/read-71399.html

最新回复(0)