Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 分层k-折叠情况下混淆矩阵和的计算_R_Machine Learning_Confusion Matrix - Fatal编程技术网

R 分层k-折叠情况下混淆矩阵和的计算

R 分层k-折叠情况下混淆矩阵和的计算,r,machine-learning,confusion-matrix,R,Machine Learning,Confusion Matrix,我是机器学习新手。我在我的数据集上应用了分层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

我是机器学习新手。我在我的数据集上应用了分层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)
})
库(MASS)
你试过这个吗

添加页边距()

->或任何边距子参数

作为论据