我在尝试创建混淆矩阵时遇到错误
Posted
技术标签:
【中文标题】我在尝试创建混淆矩阵时遇到错误【英文标题】:I'm getting an error while trying to create a confusion matrix 【发布时间】:2020-08-01 02:25:17 【问题描述】:我在尝试生成混淆矩阵时遇到以下错误 - 这曾经有效。
str(credit_test)
# Generate predicted classes using the model object
class_prediction <- predict(object=credit_model,
newdata=credit_test,
type="class")
class(class_prediction)
class(credit_test$ACCURACY)
# Calculate the confusion matrix for the test set
confusionMatrix(data=class_prediction, reference=credit_test$ACCURACY)
'data.frame': 20 obs. of 4 variables:
$ ACCURACY : Factor w/ 2 levels "win","lose": 1 1 1 2 2 1 1 1 1 1 ...
$ PM_HIGH : num 5.7 5.12 10.96 7.99 1.73 ...
$ OPEN_PRICE: num 4.46 3.82 9.35 7.77 1.54 5.17 1.88 2.65 5.71 4.09 ...
$ PM_VOLUME : num 0.458 0.676 1.591 3.974 1.785 ...
[1] "factor"
[1] "factor"
**Error in confusionMatrix(data=class_prediction, reference=credit_test$ACCURACY) :
unused arguments (data=class_prediction, reference=credit_test$ACCURACY)**
【问题讨论】:
得到以下错误而不是Error in confusionMatrix_(actual, predicted, cutoff) : argument "predicted" is missing, with no default
【参考方案1】:
出于某种原因,我不得不以这种方式运行它,有些事情发生了变化
caret::confusionMatrix(data=class_prediction,reference=credit_test$ACCURACY)
【讨论】:
以上是关于我在尝试创建混淆矩阵时遇到错误的主要内容,如果未能解决你的问题,请参考以下文章