-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing Percentage of Variance Explained for PCA #193
Comments
You and me both! The news file on the latest CRAN version has "When PCA pre-processing is conducted, the variance trace is saved in an object called For example: > library(caret)
> library(earth)
>
> set.seed(135)
> tr_dat <- twoClassSim(100)
>
> set.seed(417)
> mod <- train(Class ~ ., data = tr_dat, method = "knn",
+ preProc = c("center", "scale", "pca"))
> head(mod$preProcess$trace)
[1] 0.1208276 0.2182919 0.3141637 0.4055406 0.4818360 0.5559183
> min(which(mod$preProcess$trace > .95))
[1] 14 |
Whoops. Must have missed this in the latest version. Thanks! This is a very helpful feature! |
I would appreciate this functionality as well, but it looks like the |
I really hope this is brought back! |
Hello,
I wanted to suggest adding an element to the preProcess list so that the user can easily access the percent of variance explained for each principal component. For example, I can find the percent variance explained from prcomp by:
PCA.1 <- prcomp(iris[,1:4],
center = TRUE,
scale. = TRUE)
PCA.1$sdev / sum(PCA.1$sdev) # get percent variance explained for each principal component
There doesn't seem to be an equivalent method to do this using the result from a preProcess call such as:
library(caret)
pcaTransform = preProcess(iris[,1:4], thresh = 0.9999,
method=c("center", "scale", "pca"))
PCA.2 = predict(pcaTransform, iris[,1:4])
Thanks!
The text was updated successfully, but these errors were encountered: