[英]How to get the aggregate of all the confusion matrix in python when Stratified 10 fold cross validation is applied
I am using 10-fold cross-validation and evaluating the model on the basis of accuracy and precision.我正在使用 10 折交叉验证并根据准确性和精度评估模型。 The confusion matrix is generated 10 times for each model.混淆矩阵为每个模型生成 10 次。 Can anyone please let me know how can I aggregate the confusion matrix and calculate the accuracy?任何人都可以让我知道如何聚合混淆矩阵并计算准确度?
Thanks!!谢谢!!
You can use cross_val_predict
function as follows and use it result as confusion_matrix()
argument.您可以按如下方式使用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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.