# SMOTE sampling for multi-class data

I have a classification problem with 4 distinct classes, but imbalanced data.

dat <- data.frame(x = rnorm(40), y = rnorm(40), class = as.factor(c(rep(1,5), rep(2,5), rep(3,25), rep(4,5))))
prop.table(table(dat$class))  1: 0.125 2: 0.125 3: 0.625 4: 0.125 I tried to simply apply the SMOTE function onto the data, but that does not balance all 4 classes. library(DMwR) dat.smote <- SMOTE(class ~ ., dat) prop.table(table(dat.smote$class))


1: 0.42857143

2: 0.08571429

3: 0.45714286

4: 0.02857143

How can I balance all 4 classes to have equal numbers of observations using the SMOTE function in R?