1

I have an imbalanced dataset for training a rf model. Response variable is data$TA where TA is a factor with labels "NT" and "T" and values 1 and 2 (numeric). When attempting SMOTE:train_sm <- SMOTE(TA~., data = data), I get this error:

Error in factor(NewCases[, a], levels = 1:nlevels(data[, a]), labels = levels(data[,  : 
  invalid 'labels'; length 0 should be 1 or 2

Using the advice from previous stackoverflow posts, I have tried to convert the data$TA into:

  1. a numeric vector
  2. a factor with numeric labels (tried using both factor and as.factor)

But it did not solve my issue - the same error occured in all cases. Please tell me what else should I do to make it work?

  • 1
    Please provide a sample of your data and full code necessary to reproduce the error. See [this post for details](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – NelsonGon Aug 01 '19 at 14:12

0 Answers0