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
    Commented Mar 15, 2023 at 9:20

2 Answers 2

1
$\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$
-2
$\begingroup$

The package DMwR is being retired and should be replaced by the package themis.

My understanding is that we can't use SMOTE with weights in caret. So it's best to perform SMOTE separately and then use the balanced dataset to train in caret.

$\endgroup$
6
  • 1
    $\begingroup$ This represents really problematic statistical practice. $\endgroup$ Commented Oct 17 at 14:01
  • $\begingroup$ Can you please elaborate on your response? I am trying to build a classification tree to predict mortality. I used SMOTE to balance my dataset, but don’t know how to take care of the censoring problem since each individual in the data has different follow up time. That’s why I thought of using weights. I would really appreciate any advice. Thank you! $\endgroup$
    – Meo
    Commented Oct 19 at 6:14
  • $\begingroup$ Do you not search this site first when posting questions? This has been covered numerous times $\endgroup$ Commented Oct 19 at 12:31
  • $\begingroup$ I did. But I couldn’t find a discussion for using decision tree on censored outcome with imbalanced data. Can you please help me or guide me to the discussion? Thank you! $\endgroup$
    – Meo
    Commented Oct 19 at 14:23
  • 1
    $\begingroup$ Thank you! I read your post regarding Classification vs Prediction. fharrell.com/post/classification/…. $\endgroup$
    – Meo
    Commented Oct 23 at 15:03

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.