0 votes
1 view
in Machine Learning by (13.5k points)

I'm trying to build a predictive model in caret using PCA as pre-processing. The pre-processing would be as follows:

preProc <- preProcess(IL_train[,-1], method="pca", thresh = 0.8)

Is it possible to pass the thresh argument directly to caret's train() function? I've tried the following, but it doesn't work:

modelFit_pp <- train(IL_train$diagnosis ~ . , preProcess="pca",

thresh= 0.8, method="glm", data=IL_train)

If not, how can I pass the separate preProc results to the train() function?

1 Answer

0 votes
by (33.1k points)

You should specify additional preprocessing arguments with train control

A list of options to pass to preProcess. The type of pre-processing is passed in the pre proc option by train.

I will use the Sonar dataset from the mlbench. 

For example:

library(caret)

library(mlbench)

data(Sonar)

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

mod <- train(Class ~ ., 

             data = Sonar, 

              method = "pls",

              trControl = ctrl)

You should make sure to go through it. 

Hope this answer helps you!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...