Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k 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! Datasets In Machine Learning would be required for a better understanding of the problem. 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...