gpt4 book ai didi

r - 分层k-Fold情况下如何计算混淆矩阵之和

转载 作者:行者123 更新时间:2023-11-30 10:00:44 26 4
gpt4 key购买 nike

我是机器学习新手。我已经在我的数据集上应用了分层 k 折。我如何获得混淆矩阵的总和。

下面是我的代码

library(MASS)

cv_lda <- lapply(folds, function(x) { # start of function
# in the next two lines we will separate the Training set into it's 10 pieces
training_fold = ForwardPlayers[-x, ] # training fold = training set minus (-) it's sub test fold
test_fold = ForwardPlayers[x, ] # here we describe the test fold individually
# now apply (train) the classifer on the training_fold
classifier = lda(Rating ~ .,training_fold)
# next step in the loop, we calculate the predictions and cm and we equate the accuracy
# note we are training on training_fold and testing its accuracy on the test_fold
y_pred = predict(classifier, newdata = test_fold[-1])

cm = table(test_fold$Rating, y_pred$class)
#accuracy <- sum(diag(cm))/sum(cm)

return(cm)
})

最佳答案

你尝试过这个吗?

addmargins()

-> 或任何边距子参数

作为参数?

关于r - 分层k-Fold情况下如何计算混淆矩阵之和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59148264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com