r-caret

caret::train: specify further non-tuning parameters for mlpWeightDecay (RSNNS package)

点点圈 提交于 2020-01-01 03:52:32
问题 I have a problem with specifying the learning rate using the caret package with the method "mlpWeightDecay" from RSNNS package. The tuning parameters of "mlpWeightDecay" are size and decay. An example leaving size constant at 4 and tuning decay over c(0,0.0001, 0.001, 0.002): data(iris) TrainData <- iris[,1:4] TrainClasses <- iris[,5] fit1 <- train(TrainData, TrainClasses, method = "mlpWeightDecay", preProcess = c("center", "scale"), tuneGrid=expand.grid(.size = 4, .decay = c(0,0.0001, 0.001,

Plot ROC curve from Cross-Validation (training) data in R

前提是你 提交于 2019-12-31 10:02:10
问题 I would like to know if there is a way to plot the average ROC Curve from the cross-validation data of a SVM-RFE model generated with the caret package. My results are: Recursive feature selection Outer resampling method: Cross-Validated (10 fold, repeated 5 times) Resampling performance over subset size: Variables ROC Sens Spec Accuracy Kappa ROCSD SensSD SpecSD AccuracySD KappaSD Selected 1 0.6911 0.0000 1.0000 0.5900 0.0000 0.2186 0.0000 0.0000 0.0303 0.0000 2 0.7600 0.3700 0.8067 0.6280 0

caret - error - Something is wrong - all the ROC metric values are missing:

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-31 07:06:08
问题 i am using the caret package. At specific instances, as for example, but not exclusively per the example below, caret will produce the following error: Something is wrong; all the ROC metric values are missing: Error in train.default(x, y, weights = w, ...) : Stopping The strange thing is that caret might do this with nearly identical calls. E.g. - the first call per below works, the second call gives an error. i have had similar issue when i included e.g. the Verbose argument, keeping all

Issue using 'ROC' metric in caret train function in R

谁说我不能喝 提交于 2019-12-31 05:37:25
问题 I have an imbalanced data set with two classes therefore I thought I could use ROC as a metric instead of Accuracy to tune my model in R using caret package (I am trying different methods such as rpart, rf..etc). I thought we could extract probabilities and use ROC as a metric in decision tree type algorithms as well using caret. I illustrate my problem using a data set in caret below. There are three classes in this data but I redefined and created two classes for illustration purposes. I

How does createDataPartition function from caret package split data?

拟墨画扇 提交于 2019-12-30 09:00:38
问题 From the documentation: For bootstrap samples, simple random sampling is used. For other data splitting, the random sampling is done within the levels of y when y is a factor in an attempt to balance the class distributions within the splits. For numeric y, the sample is split into groups sections based on percentiles and sampling is done within these subgroups. For createDataPartition, the number of percentiles is set via the groups argument. I don't understand why this "balance" thing is

Extract the coefficients for the best tuning parameters of a glmnet model in caret

时光总嘲笑我的痴心妄想 提交于 2019-12-30 06:51:21
问题 I am running elastic net regularization in caret using glmnet . I pass sequence of values to trainControl for alpha and lambda, then I perform repeatedcv to get the optimal tunings of alpha and lambda. Here is an example where the optimal tunings for alpha and lambda are 0.7 and 0.5 respectively: age <- c(4, 8, 7, 12, 6, 9, 10, 14, 7, 6, 8, 11, 11, 6, 2, 10, 14, 7, 12, 6, 9, 10, 14, 7) gender <- make.names(as.factor(c(1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1)))

Additional metrics in caret - PPV, sensitivity, specificity

二次信任 提交于 2019-12-30 05:14:05
问题 I used caret for logistic regression in R: ctrl <- trainControl(method = "repeatedcv", number = 10, repeats = 10, savePredictions = TRUE) mod_fit <- train(Y ~ ., data=df, method="glm", family="binomial", trControl = ctrl) print(mod_fit) The default metric printed is accuracy and Cohen kappa. I want to extract the matching metrics like sensitivity, specificity, positive predictive value etc. but I cannot find an easy way to do it. The final model is provided but it is trained on all the data

Caret package Custom metric

倖福魔咒の 提交于 2019-12-29 18:56:48
问题 I'm using the caret function "train()" in one of my project and I'd like to add a "custom metric" F1-score. I looked at this url caret package But I cannot understand how I can build this score with the parameter available. There is an example of custom metric which is the following: ## Example with a custom metric madSummary <- function (data, lev = NULL, model = NULL) { out <- mad(data$obs - data$pred, na.rm = TRUE) names(out) <- "MAD" out } robustControl <- trainControl(summaryFunction =

Caret package Custom metric

允我心安 提交于 2019-12-29 18:55:04
问题 I'm using the caret function "train()" in one of my project and I'd like to add a "custom metric" F1-score. I looked at this url caret package But I cannot understand how I can build this score with the parameter available. There is an example of custom metric which is the following: ## Example with a custom metric madSummary <- function (data, lev = NULL, model = NULL) { out <- mad(data$obs - data$pred, na.rm = TRUE) names(out) <- "MAD" out } robustControl <- trainControl(summaryFunction =

Why is caret train taking up so much memory?

喜欢而已 提交于 2019-12-29 14:19:04
问题 When I train just using glm , everything works, and I don't even come close to exhausting memory. But when I run train(..., method='glm') , I run out of memory. Is this because train is storing a lot of data for each iteration of the cross-validation (or whatever the trControl procedure is)? I'm looking at trainControl and I can't find how to prevent this...any hints? I only care about the performance summary and maybe the predicted responses. (I know it's not related to storing data from