5
$\begingroup$

when using caret packge in the trainControl you can use "smote" sampling. what is the default parameters the train in caret are using for smote??

parameters such as: perc.over = 300, k = 8, perc.under = 100..

ctrl <- trainControl(method = "repeatedcv",
                     number = 10,
                     repeats = 10, 
                     search = "grid", 
                     returnData = TRUE,
                     returnResamp = "final",
                     savePredictions = "all",
                     classProbs = TRUE,
                     sampling = "smote",
                     summaryFunction = twoClassSummary,
                     selectionFunction = "best",
                     allowParallel = TRUE)
$\endgroup$
1
  • $\begingroup$ Opening again this question after a while... Overall, is it advisable to use caret default sampling methods? I feel the control over the rebalanced data set is a bit lost. Is it a better option to just build the dataset by themselves using a package like imbalance? $\endgroup$
    – Angel
    Mar 15, 2023 at 9:20

1 Answer 1

2
$\begingroup$

I reproduced the example of https://topepo.github.io/caret/subsampling-for-class-imbalances.html and tried another one. Results are:

perc.over = 200

perc.under = 200

It seems that the parameters are those of usage of the function SMOTE in the DMwR documentation (pag. 82):

Usage

SMOTE(form, data, perc.over = 200, k = 5, perc.under = 200, learner = NULL, ...)

In usage k = 5, but I verified only perc.over and perc.under:

library(caret)
library(DMwR)

set.seed(2969)
imbal_train <- twoClassSim(10000, intercept = -20, linearVars = 20)
table(imbal_train\$Class)

set.seed(9560)
smote_train <- SMOTE(Class ~ ., data  = imbal_train)                         
table(smote_train\$Class)[2]

perc.over <- 100*(table(smote_train\$Class)[2]-table(imbal_train\$Class)[2])/table(imbal_train\$Class)[2]
perc.under <- 100*table(smote_train\$Class)[1]/(table(smote_train\$Class)[2]-table(imbal_train\$Class)[2])

perc.over = 200

perc.under = 200

set.seed(1234)
imbal_train <- twoClassSim(10000, intercept = -40, linearVars = 40)
table(imbal_train\$Class)

set.seed(5678)
smote_train <- SMOTE(Class ~ ., data  = imbal_train)                         
table(smote_train\$Class)

perc.over <- 100*(table(smote_train\$Class)[2]-table(imbal_train\$Class)[2])/table(imbal_train$Class)[2]
perc.under <- 100*table(smote_train\$Class)[1]/(table(smote_train\$Class)[2]-table(imbal_train\$Class)[2])

perc.over = 200

perc.under = 200

$\endgroup$

Your Answer

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

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