完整报错为:ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].
解决方法
对于多分类任务,将
from sklearn.metrics import f1_score f1_score(y_test, y_pred)
改为:f1_score(y_test, y_pred,average='macro') # average按任务需要计算