在Pandas中,评估分类模型的性能通常需要使用混淆矩阵和一些评估指标。
confusion_matrix = pd.crosstab(y_true, y_pred)
from sklearn.metrics import accuracy_score, recall_score, f1_score
accuracy = accuracy_score(y_true, y_pred)
recall = recall_score(y_true, y_pred)
f1 = f1_score(y_true, y_pred)
print("Accuracy: ", accuracy)
print("Recall: ", recall)
print("F1 score: ", f1)
from sklearn.metrics import classification_report
report = classification_report(y_true, y_pred)
print(report)
通过以上方法,可以在Pandas中评估分类模型的性能并获取详细的性能指标。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Pandas中怎么应用条件格式