R的ROSE包中的accurity.meas函数

R的ROSE包中的accurity.meas函数,r,machine-learning,r-caret,R,Machine Learning,R Caret,我使用的是R中ROSE软件包的accurity.meas函数。我得到的错误响应必须有两个级别。如此检查 参数响应和预测值均为1。但两者都是数字。accurity.meas函数的可用性是否存在一些限制 注意-答案是错误的,但与错误无关 在函数中,您使用的是predicted1,但您显示的是predicted。对不起,实际上predicted和predicted1是相同的。只是使用了round函数来确保所有值都是整数。现在更正。显示predicted1的结果。@LyzandeR我已经更正了问题。你能

我使用的是R中ROSE软件包的accurity.meas函数。我得到的错误响应必须有两个级别。如此检查 参数响应和预测值均为1。但两者都是数字。accurity.meas函数的可用性是否存在一些限制

注意-答案是错误的,但与错误无关


在函数中,您使用的是
predicted1
,但您显示的是
predicted
。对不起,实际上predicted和predicted1是相同的。只是使用了round函数来确保所有值都是整数。现在更正。显示predicted1的结果。@LyzandeR我已经更正了问题。你能帮我解决我对你使用的函数的疑问吗?你正在给我们展示的是
predicted1
。对不起,实际上predicted和predicted1是一样的。只是使用了round函数来确保所有值都是整数。现在更正。显示predicted1的结果。@LyzandeR我已经更正了问题。你能帮我解决我的疑问吗
accuracy.meas(test$Walc,predicted1,threshold = 0.5)
    Error in accuracy.meas(response=test$Walc,predicted= predicted1, threshold = 0.5) : 
      Response must have two levels.

>test$Walc
  [1] 1 1 1 3 3 3 1 1 2 2 1 2 1 1 3 3 1 1 1 1 3 1 1 4 2 1 1 1 1 4 4 4 5 1 1 1 1 3 1 2 3
 [42] 1 5 1 4 4 1 2 2 2 1 2 2 3 2 3 1 2 1 5 1 1 3 2 2 1 1 1 1 1 1 1 2 1 1 3 3 3 2 3 1 2
 [83] 2 2 1 1 3 1 1 1 2 3 3 1 1 3 1 2 1 5 2 2 1 2 1 1 2 2 1 1 3 1 2 1 1 1 3 1 1 1 1 1 1
[124] 3 3 3 4 1 1 1 1 4 1 1 1 1 3 2 1 3 3 1 1 1 1 1 1 1 1 5 1 1 1 3 1 1 1 3 4 1 3 2 4 5
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