r-caret

How to get predictions for each fold in 10-fold cross-validation of the best tuned hyperparameters using caret package in r?

心不动则不痛 提交于 2021-02-10 13:28:16
问题 I was trying to run SVM model using 10-fold cross-validation with 3 repeats using the caret package in R. I want to get the prediction results of each fold using the best tuned hyperparameters. I am using the following code # Load packages library(mlbench) library(caret) # Load data data(BostonHousing) #Dividing the data into train and test set set.seed(101) sample <- createDataPartition(BostonHousing$medv, p=0.80, list = FALSE) train <- BostonHousing[sample,] test <- BostonHousing[-sample,]

Custom Performance Function in caret Package using predicted Probability

独自空忆成欢 提交于 2021-02-10 10:40:48
问题 This SO post is about using a custom performance measurement function in the caret package. You want to find the best prediction model, so you build several and compare them by calculating a single metric that is drawn from comparing the observation and the predicted value. There are default functions to calculate this metric, but you can also define your own metric-function. This custom functions must take obs and predicted values as input. In classification problems (let's say only two

Difference between AUPRC in caret and PRROC

自作多情 提交于 2021-02-09 08:37:23
问题 I'm working in a very unbalanced classification problem, and I'm using AUPRC as metric in caret. I'm getting very differents results for the test set in AUPRC from caret and in AUPRC from package PRROC. In order to make it easy, the reproducible example uses PimaIndiansDiabetes dataset from package mlbench: rm(list=ls()) library(caret) library(mlbench) library(PRROC) #load data, renaming it to 'datos' data(PimaIndiansDiabetes) datos=PimaIndiansDiabetes[,1:9] # training and test set.seed(998)

Difference between AUPRC in caret and PRROC

大憨熊 提交于 2021-02-09 08:34:51
问题 I'm working in a very unbalanced classification problem, and I'm using AUPRC as metric in caret. I'm getting very differents results for the test set in AUPRC from caret and in AUPRC from package PRROC. In order to make it easy, the reproducible example uses PimaIndiansDiabetes dataset from package mlbench: rm(list=ls()) library(caret) library(mlbench) library(PRROC) #load data, renaming it to 'datos' data(PimaIndiansDiabetes) datos=PimaIndiansDiabetes[,1:9] # training and test set.seed(998)

Difference between AUPRC in caret and PRROC

南笙酒味 提交于 2021-02-09 08:33:26
问题 I'm working in a very unbalanced classification problem, and I'm using AUPRC as metric in caret. I'm getting very differents results for the test set in AUPRC from caret and in AUPRC from package PRROC. In order to make it easy, the reproducible example uses PimaIndiansDiabetes dataset from package mlbench: rm(list=ls()) library(caret) library(mlbench) library(PRROC) #load data, renaming it to 'datos' data(PimaIndiansDiabetes) datos=PimaIndiansDiabetes[,1:9] # training and test set.seed(998)

Difference between AUPRC in caret and PRROC

蓝咒 提交于 2021-02-09 08:32:47
问题 I'm working in a very unbalanced classification problem, and I'm using AUPRC as metric in caret. I'm getting very differents results for the test set in AUPRC from caret and in AUPRC from package PRROC. In order to make it easy, the reproducible example uses PimaIndiansDiabetes dataset from package mlbench: rm(list=ls()) library(caret) library(mlbench) library(PRROC) #load data, renaming it to 'datos' data(PimaIndiansDiabetes) datos=PimaIndiansDiabetes[,1:9] # training and test set.seed(998)

prSummary in r caret package for imbalance data

一曲冷凌霜 提交于 2021-02-08 10:13:56
问题 I have an imbalanced data, and I want to do stratified cross validation and use precision recall auc as my evaluation metric. I use prSummary in r package caret with stratified index, and I encounter an error when computing performance. The following is a sample which can be reproduced. I found that there are only ten sample to compute p-r auc, and because of the imbalanced, there is only one class so that it cannot compute p-r auc. (The reason that I found that only ten sample to compute p-r

R caret unusually slow when tuning SVM with linear kernel

家住魔仙堡 提交于 2021-02-07 18:31:28
问题 I have observed a very strange behavior when tuning SVM parameters with caret . When training a single model without tuning, SVM with radial basis kernel takes more time than SVM with linear kernel, which is expected. However, when tuning SVM with both kernels over the same penalty grid, SVM with linear kernel takes substantially more time than SVM with radial basis kernel. This behavior can be easily reproduced in both Windows and Linux with R 3.2 and caret 6.0-47. Does anyone know why

How to plot the neural network found by train

假装没事ソ 提交于 2021-02-05 10:13:08
问题 I am trying to generate a plot of the best neural network found using the following code with a very tiny dataset. This gives me a plot of the accuracy not the neural net. my.grid <- expand.grid(.decay = c(0.5, 0.1), .size = c(5, 6, 7)) nn.cr <- train(Acceptance ~ Salt + Fat, data = df, method = "nnet", tuneGrid = my.grid) plot(nn.cr) 来源: https://stackoverflow.com/questions/64824753/how-to-plot-the-neural-network-found-by-train

Logistic Regression in Caret - No Intercept?

旧巷老猫 提交于 2021-02-05 06:34:24
问题 Performing logistic regression in R using the caret package and trying to force a zero intercept such that probability at x=0 is .5. In other forms of regression, it seems like you can turn the intercept off using tunegrid, but that has no functionality for logistic regression. Any ideas? model <- train(y ~ 0+ x, data = data, method = "glm", family = binomial(link="probit"), trControl = train.control) And yes, I "know" that the probability at x=0 should be .5, and thus trying to force it. 回答1