Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oversample() gives an error if ratio >= 0.98 for SMOTE #10

Open
sohih opened this issue May 14, 2021 · 1 comment
Open

oversample() gives an error if ratio >= 0.98 for SMOTE #10

sohih opened this issue May 14, 2021 · 1 comment

Comments

@sohih
Copy link

sohih commented May 14, 2021

Sample code below to illustrate the issue. Documentation says that ratio can be between 0 and 1. However, oversample() gives an error if the ratio specified is really close to 1, and also error for ratio = 1. How can a user work around this?

newDataset <- oversample(glass0, ratio = 0.9, method = "SMOTE") #No problem
newDataset <- oversample(glass0, ratio = 1, method = "SMOTE")
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'
newDataset <- oversample(glass0, ratio = 1.0, method = "SMOTE")
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'
newDataset <- oversample(glass0, ratio = 0.95, method = "SMOTE")
newDataset <- oversample(glass0, ratio = 0.99, method = "SMOTE")
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'
newDataset <- oversample(glass0, ratio = 0.98, method = "SMOTE")
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'
newDataset <- oversample(glass0, ratio = 0.97, method = "SMOTE") #No error for ratio = 0.97

@sohih
Copy link
Author

sohih commented May 14, 2021

I also found that this issue is dataset specific. With another dataset, I found that ratio = > 0.95 gives the same kind of error.

Sample code and resulting error:
dat3_L_M_SMOTE = oversample(dat3_L_M_numeric2, ratio=0.95, method= "SMOTE", classAttr = "sub_0_80")
Error in sample.int(length(x), size, replace, prob) :
cannot take a sample larger than the population when 'replace = FALSE'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant