Pass PCA preprocessing arguments to train()

落爺英雄遲暮 提交于 2019-12-03 10:32:43

As per the documentation, you specify additional preprocessing arguments with trainControl

?trainControl

...
preProcOptions  

A list of options to pass to preProcess. The type of pre-processing 
(e.g. center, scaling etc) is passed in via the preProc option in train.
...

Since your dataset is not reproducible, let's look at an example. I will use the Sonar dataset from mlbench and use the pls algorithm just for fun.

library(caret)
library(mlbench)

data(Sonar)

ctrl <- trainControl(preProcOptions = list(thresh = 0.95))

mod <- train(Class ~ ., 
             data = Sonar, 
              method = "pls",
              trControl = ctrl)

Although documentation isn't the most exciting read, definitely make sure to try to go through it. Package authors work hard to create documentation and there are many wonders to be found within.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!