gpt4 book ai didi

r - "Error in table(pred = prediction, true = W[, 8]) : all arguments must have the same length"

转载 作者:行者123 更新时间:2023-11-30 08:28:27 26 4
gpt4 key购买 nike

这是我的数据:

 Anon_Student_Id           Problem_Hierarchy Problem_Name Problem_View Number_Of_Steps Sum_Of_Steps_Duration Sum_Of_Hints result1      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG21            8               3                    28            0      12      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG21            9               3                    37            0      03      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG21           10               3                    50            0      04      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG22            1               3                    78            0      05      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG22            2               3                    41            0      16      80nlN05JQ6 Unit ES_01, Section ES_01-6         EG22            3               3                    92            0      0

I'm trying to predict the attribute "result" by SVM model :

model<-svm(result~., scale=FALSE, data=W)

prediction <- predict(model, W[,-8])

table(pred = prediction, true = W[,8])

But I get this error:

"Error in table(pred = prediction, true = W[, 8]) : 
all arguments must have the same length"

当我检查时,我得到:length(pred)=2042 和 length(true)=2043

为什么我会收到此错误? (我的意思是-为什么我得到不同的长度?“pred”和“true”应该具有相同的长度)

谢谢!

最佳答案

问题已解决:我使用 na.omit(W) 删除了数据的所有 na 值,然后它就起作用了。谢谢!

关于r - "Error in table(pred = prediction, true = W[, 8]) : all arguments must have the same length",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17155614/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com