用了caret包的train函数训练模型,然后用predict函数做预测,方法是偏最小二乘(设定了成分数14)。
请问我的预测结果myresult 出来的为什么是向量带一个数组呢?
> plsFit <- plsr(Solubility ~ ., data = trainingData
+ ,ncomp=14
+ ,method="kernelpls"
+ , scale = TRUE, center = TRUE)
>
> myresult <- predict(plsFit, solTestXtrans,ncomp=14)
>
> str(myresult)
num [1:316, 1, 1] 0.551 0.142 -0.493 0.506 0.106 ...
- attr(*, "dimnames")=List of 3
..$ : chr [1:316] "20" "21" "23" "25" ...
..$ : chr "Solubility"
..$ : chr "14 comps"
如果尝试把myresult转换为数据框,数据框的列名甚至是【 Solubility.14 comps】
> temp<-as.data.frame(myresult)
> str(temp)
'data.frame': 316 obs. of 1 variable:
$ Solubility.14 comps: num 0.551 0.142 -0.493 0.506 0.106 ...
> head(temp)
Solubility.14 comps
20 0.5506072
21 0.1418576
23 -0.4927215
25 0.5059239
28 0.1064888
31 1.6412768


雷达卡



京公网安备 11010802022788号







