You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
step_smote throws an error when a class is marginally below the target upsampling threshold. This only occurs in rare cases when smote tries to synthesize a fraction of a sample (n < 1).
The issue occurs in themis:::smote_impl. When samples_needed contains a number smaller than 1, themis:::smote_data returns an empty matrix, subsequently causing an error at the line out_df[var] <- data[[names(samples_needed)[i]]][[var]][1]
One quick solution might be to floor the ratio_target when checking which classes need to be upsampled in themis:::smote_impl, as below. This would ignore the variables fractionally below the target threshold. which_upsample <- which(table(df[[var]]) < ratio_target) # orig which_upsample <- which(table(df[[var]]) < floor(ratio_target)) # possible solution
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
The problem
step_smote
throws an error when a class is marginally below the target upsampling threshold. This only occurs in rare cases when smote tries to synthesize a fraction of a sample (n < 1).The issue occurs in
themis:::smote_impl
. Whensamples_needed
contains a number smaller than 1,themis:::smote_data
returns an empty matrix, subsequently causing an error at the lineout_df[var] <- data[[names(samples_needed)[i]]][[var]][1]
One quick solution might be to
floor
theratio_target
when checking which classes need to be upsampled inthemis:::smote_impl
, as below. This would ignore the variables fractionally below the target threshold.which_upsample <- which(table(df[[var]]) < ratio_target) # orig
which_upsample <- which(table(df[[var]]) < floor(ratio_target)) # possible solution
Reproducible example
Created on 2023-02-08 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: