def eval_performance(y_true, y_pred):
'''
Evaluate the performance of a multiclass classification model.
:param y_true: the gold-standard labels
:param y_pred: the predictions
:return: mean F1
'''
pre, rec, f1, support = metrics.precision_recall_fscore_support(y_true, y_pred, average='weighted')
print '=== Performance ==='
print 'Mean precision: %.03f%%' % pre # (100*sum(pre * support)/sum(support))
print 'Mean recall: %.03f%%' % rec # (100*sum(rec * support)/sum(support))
print 'Mean F1: %.03f%%' % f1 # mean_f1
return pre, rec, f1, support
评论列表
文章目录