本文介绍了“表中的错误(pred =预测,true = W [,8]):所有参数必须具有相同的长度"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的数据
Anon_Student_Id Problem_Hierarchy Problem_Name Problem_View Number_Of_Steps Sum_Of_Steps_Duration Sum_Of_Hints result
1 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 8 3 28 0 1
2 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 9 3 37 0 0
3 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 10 3 50 0 0
4 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 1 3 78 0 0
5 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 2 3 41 0 1
6 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 3 3 92 0 0
我正在尝试通过SVM模型预测属性结果":
I'm trying to predict the attribute "result" by SVM model :
预测<-预测(模型,W [,-8])
prediction <- predict(model, W[,-8])
table(pred =预测,true = W [,8])
table(pred = prediction, true = W[,8])
但是我得到这个错误:
"Error in table(pred = prediction, true = W[, 8]) :
all arguments must have the same length"
当我检查它时,我得到:length(pred)= 2042和length(true)= 2043
When I checked it I got: length(pred)=2042 and length(true)=2043
为什么我会收到此错误? (我的意思是-为什么我得到不同的长度?"pred"和"true"应该具有相同的长度)
Why I'm getting this error?? (I mean- why i'm getting different lengths? "pred" and "true" are supposed to have the same length)
谢谢!
推荐答案
问题已解决:我使用na.omit(W)摆脱了我的数据的所有na值,然后它起作用了.谢谢!
Problem solved:i got rid of all the na values of my data using na.omit(W) and then it worked. thank you!
这篇关于“表中的错误(pred =预测,true = W [,8]):所有参数必须具有相同的长度"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!