0

So whenever I try to use some imbalance function on my dataset I get this error:

 Error in Ops.data.frame(dataset[, classAttr], minorityClass) : 
  ‘==’ only defined for equally-sized data frames

This is my code:

dset <- read_csv("C:/Users/Downloads/streaming.csv") %>% select(-X1)

head(dset, 10)

imbalanceRatio(dset, classAttr = "cont_subs")

The task is a binary classification of whether the user continues his subscription to the service or not, with the "cont_subs" column containing only "Yes" or "No"

There was a similar question where the fix was adding classAtr to the function but adding classAtr to the function for me causes this error. So far I wasnt able to find someone getting the same error using the same package.

If I remove the classAtr from the imbalanceRatio func I get

   Error: Can't subset columns that don't exist.
x The column `Class` doesn't exist.
Run `rlang::last_error()` to see where the error occurred.

I'm new to R so excuse me if there's something obvious I'm missing.

DolceVita34
  • 115
  • 1
  • 1
  • 6
  • In order to make your question reproducible and thus answerable, we need minimal, self-contained code and data so that we are able to reproduce your problem on our machine, please follow these simple guidelines: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610. – jay.sf May 23 '20 at 08:06
  • When I use a generate simple dataset as the one in the link you posted, the command seems to work set.seed(1) `Data <- data.frame( X = sample(1:10), Y = sample(c("yes", "no"), 10, replace = TRUE) )` `imbalanceRatio(Data, classAttr = "Y")` However the dataset I'm using is huge in comparison and much more elaborate and I'm not exactly sure how to provide a reproducable snippet of it. – DolceVita34 May 23 '20 at 08:20

0 Answers0