r-caret

How to plot ROC curves for every cross-validations using Caret

房东的猫 提交于 2020-03-22 07:42:09
问题 I have the following code: library(mlbench) library(caret) library(ggplot2) set.seed(998) # Prepare data ------------------------------------------------------------ data(Sonar) my_data <- Sonar # Cross Validation Definition --------------------------------------------------- fitControl <- trainControl( method = "cv", number = 10, classProbs = T, savePredictions = T, summaryFunction = twoClassSummary ) # Training with Random Forest -------------------------------------------------------------

R caret: How do I apply separate pca to different dataframes before training?

冷暖自知 提交于 2020-03-19 02:29:55
问题 I use caret in R. My final goal is to submit different dataframes to separate preProcess pca and then put the PCA-components together in one training with ridge regression. However, see example code below where I don't get the same results when applying pca in preProcess within versus outside/before train function. Why do I not get the same results? And how do I achieve my main goal in the best way? #Sample data s <- c(-0.412440717220306, -0.459911376237869, -0.234769582748413, -0

R caret: How do I apply separate pca to different dataframes before training?

你说的曾经没有我的故事 提交于 2020-03-19 02:27:01
问题 I use caret in R. My final goal is to submit different dataframes to separate preProcess pca and then put the PCA-components together in one training with ridge regression. However, see example code below where I don't get the same results when applying pca in preProcess within versus outside/before train function. Why do I not get the same results? And how do I achieve my main goal in the best way? #Sample data s <- c(-0.412440717220306, -0.459911376237869, -0.234769582748413, -0

Revert transformation preprocess caret

为君一笑 提交于 2020-03-18 09:27:35
问题 I transformed data to attend to the requirements of a linear model (normally distributed): d.reg1 = d.reg %>% preProcess("YeoJohnson") %>% predict(d.reg) The adjusted model: fit = lm(log10(Qmld)~log10(Peq750), data = d.reg1) #potential regression Predicted data: a=10^fit$coefficients[1] b=fit$coefficients[2] d.reg1$Qmld_predita=a*d.reg1$Peq750^b How could I untransform d.reg1$Qmld_predita , since the model was fitted to transformed data and this has no physical significance for me? 回答1: Here

Caret package - glmnet variable importance

爷,独闯天下 提交于 2020-02-24 11:30:15
问题 I am using the glmnet package to perform a LASSO regression. I am now working on feature importance using the caret package. What I don't understand is the value of the importance. Could anyone enlighten me? Is there any formula to calculate these values or does that mean that these values are based on the beta values? ROC curve variable importance only 7 most important variables shown (out of 25) Importance feature1 0.8974 feature2 0.8962 feature3 0.8957 feature4 0.8744 feature5 0.8701

Variable importance with ranger

十年热恋 提交于 2020-02-18 08:43:17
问题 I trained a random forest using caret + ranger . fit <- train( y ~ x1 + x2 ,data = total_set ,method = "ranger" ,trControl = trainControl(method="cv", number = 5, allowParallel = TRUE, verbose = TRUE) ,tuneGrid = expand.grid(mtry = c(4,5,6)) ,importance = 'impurity' ) Now I'd like to see the importance of variables. However, none of these work : > importance(fit) Error in UseMethod("importance") : no applicable method for 'importance' applied to an object of class "c('train', 'train.formula')

Variable importance with ranger

谁都会走 提交于 2020-02-18 08:42:47
问题 I trained a random forest using caret + ranger . fit <- train( y ~ x1 + x2 ,data = total_set ,method = "ranger" ,trControl = trainControl(method="cv", number = 5, allowParallel = TRUE, verbose = TRUE) ,tuneGrid = expand.grid(mtry = c(4,5,6)) ,importance = 'impurity' ) Now I'd like to see the importance of variables. However, none of these work : > importance(fit) Error in UseMethod("importance") : no applicable method for 'importance' applied to an object of class "c('train', 'train.formula')

R - error installing caret package

二次信任 提交于 2020-02-01 05:51:14
问题 > Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), > versionCheck = vI[[j]]) : namespace ‘pbkrtest’ 0.4-2 is being > loaded, but >= 0.4.4 is required > Error: package or namespace load > failed for ‘caret’ Caret was working fine until I tried to load Rcpp and it messed everything up. I searched the answers for a similar problem with caret but the solutions posted did not seem to work on mine. I followed: install.packages("caret", dependencies = TRUE) But it did not work. 回答1: I

createGrid function from caret package - Was it removed?

寵の児 提交于 2020-01-21 12:21:29
问题 I'm using caret package (version 6.0-24) in R (version 3.0.2). The function createGrid was actually removed? In caret version 5.17-7 the function remains. 回答1: the function createGrid was removed from the version 6.0-24 (http://cran.r-project.org/web/packages/caret/caret.pdf) 来源: https://stackoverflow.com/questions/22275173/creategrid-function-from-caret-package-was-it-removed

createGrid function from caret package - Was it removed?

旧城冷巷雨未停 提交于 2020-01-21 12:20:41
问题 I'm using caret package (version 6.0-24) in R (version 3.0.2). The function createGrid was actually removed? In caret version 5.17-7 the function remains. 回答1: the function createGrid was removed from the version 6.0-24 (http://cran.r-project.org/web/packages/caret/caret.pdf) 来源: https://stackoverflow.com/questions/22275173/creategrid-function-from-caret-package-was-it-removed