【问题标题】:How to get the aggregate of all the confusion matrix in python when Stratified 10 fold cross validation is applied应用分层10折交叉验证时如何在python中获取所有混淆矩阵的聚合
【发布时间】:2020-03-28 04:13:36
【问题描述】:

我正在使用 10 折交叉验证,并根据准确度和精度评估模型。 每个模型生成 10 次混淆矩阵。谁能告诉我如何聚合混淆矩阵并计算准确性?

谢谢!!

【问题讨论】:

  • 您能否举例说明您的输入是什么以及您希望在输出中看到什么?

标签: python machine-learning numpy-ndarray confusion-matrix


【解决方案1】:

您可以如下使用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)

【讨论】:

    【解决方案2】:

    您需要提供更多关于您拥有的数据格式的信息!

    如果你使用的是 tensorflow,可以参考这个source

    【讨论】:

      猜你喜欢
      • 2014-04-19
      • 2018-09-10
      • 2017-03-03
      • 2012-04-01
      • 2012-05-11
      • 1970-01-01
      • 2018-12-06
      • 2021-02-13
      • 2019-04-13
      相关资源
      最近更新 更多