报错 Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].
解决:加上参数,average='micro'
源代码:
# precision
import numpy as np
from sklearn.metrics import precision_score
y_true = [1,1,0,0]
y_pre = [1,2,1,0]
print('precision指标为:',precision_score(y_true,y_pre))
报错:
加上参数:
# precision
import numpy as np
from sklearn.metrics import precision_score
y_true = [1,1,0,0]
y_pre = [1,2,1,0]
print('precision指标为:',precision_score(y_true,y_pre,average='micro'))
成功: