我想将KPCA应用于我的训练数据,然后再将其传递给我的SVM,这似乎与kernlab完美配合。之后我想将我的测试输入嵌入到新空间中,以便用我的SVM进行预测。纪录片建议使用预测功能,这会给我一个错误:
dataTrain=as.xts(data)
inputTrain=dataTrain[1:settings$windowTrain,1:ncol(dataTrain)-1]
outputTrain=dataTrain[1:settings$windowTrain,ncol(dataTrain)]
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
inputTrain=kpcaa@pcv
predict(object = kpcaa,newdata=inputTest)
predict(object = kpcaa,newdata=inputTest)
Error in .local(object, ...) :
unused argument (newdata = c(0.00065527734617099, -0.00281135973754587, 0.00121922641129046, -0.00356807890285626, 0.00140997344409755, 0.000281756282681123, 0.000657122764787132, -0.000469329337005497, -0.000187793427781635, 0.00046941746156115, -0.000751173744242273, 0.000281756282681123, 0.000187793427781635, -0.000469549710462758, 0.000751173744242273, 0.00140693171451645, -0.000937734502324261, -0.000469197212192185, 0.00112570368360299, -0.0014073277173825, 0.0014073277173825, -0.00112570368360299,
0.000656814473530609, -0.00253580788619168, 0.00187899341266107, -0.00310223515540553, 0.00282061112162602, 0.00121979841537989, -0.00150150178359798, 0.000469461536250826, -0.00140904630893512, -0.000188022939352273, -0.000470212074305643, -0.000282233408900545, 0.00094046842255846, -0.000188022939352273, -0.000470212074305643, -0.000470433277716786, 0.00234995643227709, 0.000938438507310124, 0.000937558666089799, 0.0034613440236777, 0.00493736156014979, 0.00046453292050951
有人可以帮我这个吗? 谢谢!
答案 0 :(得分:0)
幸运的是我发现代码中存在错误。
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
必须是......
kpcaa=kpca(~.,data=inputTrain,...)