1

有一个分类问题,我在 R 中使用 SVM 进行预测。在数据集中,有整数和分类变量。使用 predict 方法进行预测时出现错误。

    svp3c <- ksvm(input_dataset3$isCRgt3~., data=input_dataset3,type="C-svc")
    p3<-predict(svp3c,newdata=input_dataset_prediction[,-1],type="response")

    error :: Error in which.max(votematrix[, x]) : subscript out of bounds

对于这个建模

第一:使用训练数据集开发模型

第二:保存和加载模型以在测试数据集上进行预测

Training Dataset sample

Headning :
head1(int),head2(character-url),head3(character-url),head4(character-url),head5(character),head6(character),haed7(int),head8(int),head9(int),head10(int),head11(int)

Data:    
"0","10","/","/index.php?main_page=logoff","(not set)","rc317a","organic","0","4","20092","5023","0"
"1","11","/","/offwhite-churidar-kameez-set-p-17381.html","(not set)","rc317a","organic","0","4","20092","5023","0"

[下载样本数据集] http://www.2shared.com/file/tQRapbBt/input_dataset3.html

【重现R脚本】http://www.2shared.com/file/NpDs5V-9/data1_train.html

任何人都可以提出建议吗?

4

1 回答 1

0

我在使用不同的数据集时遇到了同样的问题。我首先注意到 predict 返回的预测少于测试用例。事实证明,测试数据框中的整数变量之一包含 NA。将 NA 更改为 -1 消除了该错误。
TBC - 我没有考虑过将变量设置为 -1 的含义,但它已经消除了错误,现在得到了正确数量的预测。

于 2013-12-01T22:38:56.523 回答