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
我添加了數據集和代碼。請檢查它。 –