【问题标题】:Svm modeling :: Error in which.max(votematrix[, x]) : subscript out of boundsSvm 建模 :: Error in which.max(votematrix[, x]) : subscript out of bounds
【发布时间】:2012-10-07 13:25:53
【问题描述】:

有一个分类问题,我在 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

谁能给点建议?

【问题讨论】:

  • input_dataset_prediction[,-1] 的列数是否与 input_dataset3 减一的列数完全相同?此外,svp3c &lt;- ksvm( isCRgt3~., data=input_dataset3,type="C-svc") 应该可以工作。
  • 感谢一月的建议,
  • @january,我在 input_dataset_prediction 和 input_dataset3 中的列数相同。
  • 你能把你的数据文件贴在某个地方吗?

标签: r svm prediction


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-20
    • 2016-05-12
    相关资源
    最近更新 更多