Error 'names' attribute [35563] must be the same length as the vector [1] after running SMOGNRegress in R

67 views Asked by At

I'm trying to oversample an imbalanced dataset with a continuous target variable using SMOGNRegress from the UBL package in R.

When I run the code:

SMOGNRegress(Deceased~., normalized_data, rel = "auto", thr.rel = 0.9999, C.perc = "balance", k = 2, repl = F, dist = "Euclidean", pert = 0.01)

I get the following error:

'names' attribute [35563] must be the same length as the vector [1]

From similar questions regarding this error, I saw that it is an issue of lengths not matching, but I cannot wrap my head around how to fix that in order to generate the new oversampled data set.

1

There are 1 answers

0
Justin On

Making sure this function knows that "normalized_data" is a data frame worked for me.

SMOGNRegress(Deceased~., as.data.frame(normalized_data), rel = "auto", thr.rel = 0.9999, C.perc = "balance", k = 2, repl = F, dist = "Euclidean", pert = 0.01)