[英]How to get the aggregate of all the confusion matrix in python when Stratified 10 fold cross validation is applied
我正在使用 10 折交叉验证并根据准确性和精度评估模型。 混淆矩阵为每个模型生成 10 次。 任何人都可以让我知道如何聚合混淆矩阵并计算准确度?
谢谢!!
您可以按如下方式使用cross_val_predict
函数并将其结果用作confusion_matrix()
cross_val_predict
confusion_matrix()
参数。
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import cross_val_predict
y_pred = cross_val_predict(clf, x, y, cv=5)
cm = confusion_matrix(y, y_pred)
您需要提供更多有关您拥有的数据格式的信息!
如果您使用的是 tensorflow,则可以参考此来源
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.