11
$\begingroup$

I am using the caret package in R for training of binary SVM classifiers. For reduction of features I am preprocessing with PCA using the built in feature preProc=c("pca") when calling train(). Here are my questions:

  1. How does caret select principal components?
  2. Is there a fixed number of principal components that is selected?
  3. Are principal components selected by some amount of explained variance (e.g. 80%)?
  4. How can I set the number of principal components used for classification?
  5. (I understand that PCA should be part of the outer cross-validation to allow reliable prediction estimates.) Should PCA also be implemented in the inner cross-validation cycle (parameter estimation)?
  6. How does caret implement PCA in the cross-validation?
$\endgroup$
1

1 Answer 1

14
$\begingroup$

By default, caret keeps the components that explain 95% of the variance.
But you can change it by using the thresh parameter.

# Example
preProcess(training, method = "pca", thresh = 0.8)

You can also set a particular number of components by setting the pcaComp parameter.

# Example
preProcess(training, method = "pca", pcaComp = 7)

If you use both parameters, pcaComp has precedence over thresh.

Please see: https://www.rdocumentation.org/packages/caret/versions/6.0-77/topics/preProcess

$\endgroup$
2
  • $\begingroup$ Unfortunately the link is broken $\endgroup$
    – R Kiselev
    Sep 28, 2017 at 10:48
  • $\begingroup$ corrected the link $\endgroup$ Sep 28, 2017 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.