【问题标题】:How to calculate sum of confusion matrix in the case of stratified k- Fold在分层k-Fold的情况下如何计算混淆矩阵的总和
【发布时间】:2019-12-02 23:42:04
【问题描述】:

我是机器学习的新手。我在我的数据集上应用了分层的 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)
})

【问题讨论】:

    标签: r machine-learning confusion-matrix


    【解决方案1】:

    你试过了吗?

    addmargins()

    -> 或任何边距子参数

    作为论据?

    【讨论】:

      【解决方案2】:

      如果您的意思是矩阵中的全部数据的总和来衡量 P+N 的准确度指标,您可以试试这个: sum(sum(confusion_matrix))

      【讨论】:

      • 请在答案中包含额外的详细信息,并尝试始终将代码包含在“代码示例”块中。
      猜你喜欢
      • 2019-09-28
      • 1970-01-01
      • 2017-02-25
      • 2018-04-01
      • 2017-12-20
      • 2017-09-27
      • 2017-09-25
      • 2021-11-27
      相关资源
      最近更新 更多