import seaborn as sns
sns.heatmap(confusion_matrix(y_test, y_pred), annot = True)
ValueError Traceback (most recent call last)
<ipython-input-21-ee6823d584e9> in <cell line: 1>()
----> 1 sns.heatmap(confusion_matrix(y_test, y_pred), annot = True)
/usr/local/lib/python3.10/dist-packages/sklearn/metrics/_classification.py in confusion_matrix(y_true, y_pred, labels, sample_weight, normalize)
317 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
318 if y_type not in ("binary", "multiclass"):
--> 319 raise ValueError("%s is not supported" % y_type)
320
321 if labels is None:
ValueError: multilabel-indicator is not supported
from sklearn.utils.multiclass import type_of_target
>>> type_of_target([1.0, 2.0])
'binary'
>>> type_of_target([1, 0, 2])
'multiclass'
>>> type_of_target([1.0, 0.0, 3.0])
'multiclass'
>>> type_of_target(['a', 'b', 'c'])
'multiclass'
根据您的 y_pred 的外观,您需要对其进行分类以适应上述模式,例如不是单热编码。您可能必须首先按以下方式对模型输出进行后处理
y_pred = outputs.argmax(axis=1)