Click here to access the train and test data I used.我是SVM的新成员。我正在尝试R中的svm包来训练我的数据,其中包含40个属性和39个标签。所有属性都是双重类型(大多数是0或1,因为我在分类属性上执行了虚拟编码),类标签是不同的字符串,后来我转换为一个因子,现在是整数类型。R中的prediction.svm中的错误
model=svm(Category~.,data=train1,scale=FALSE)
p1=predict(model,test1,"prob")
这是我得到的结果,我一旦使用SVM训练模型。
Call:
svm(formula = Category ~ ., data = train1, scale = FALSE)
Parameters:
SVM-Type: C-classification
SVM-Kernel: radial
cost: 1
gamma: 0.02564103
Number of Support Vectors: 2230
我用了预测功能
Error in predict.svm(model, test1, "prob") :
NAs in foreign function call (arg 1)
In addition: Warning message:
In predict.svm(model, test1, "prob") : NAs introduced by coercion
我不理解为什么这个错误出现,我检查了我的训练数据没有人的所有属性都NA在他们。请帮我解决一下这个。 谢谢
您应该提供包含示例数据以重现错误的[可重现示例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。问题可能与您的数据有关,但这是您未显示的部分,因此很难说出可能的错误。 – MrFlick
我添加了数据集和代码。请检查它。 –