我在尝试创建混淆矩阵时遇到错误

问题描述 投票:0回答:1

我在尝试生成混淆矩阵时收到以下错误-这曾经起作用。

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)**
r classification caret confusion-matrix
1个回答
0
投票

尝试以下操作

confusionMatrix(table(data=class_prediction, reference=credit_test$ACCURACY))
© www.soinside.com 2019 - 2024. All rights reserved.