I'm building a multilabel classifier, when I try to call the classification report I get the following error: ValueError: All labels must be in [0, n labels) for multilabel targets. Got 6 > 2, following there's a minimal example that produces the error
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.metrics import classification_report
import pandas as pd
a = [
[3, 4],
[6],
[3],
[],
[6, 4]
]
bin = MultiLabelBinarizer()
bin.fit(a)
a = bin.transform(a)
report = classification_report(
a,
a,
output_dict=True,
zero_division=0,
labels=bin.classes_
)
print(report)
when I try to convert classes to strings I get the following error: TypeError: '>=' not supported between instances of 'str' and 'int'. If I comment out labels=bin.classes_ everything works, but I'd like to have the original classes in the report. How can I solve it? Is it a bug?