Skip to contents

Transition matrix driven oversampling with MCSMOTE.

Usage

MCSMOTE(x, y, thresh_qntl = 0.1, ovRate = 1, tol = 1e-04, max_iter = 1000, ...)

Arguments

x

feature matrix or dataframe.

y

a factor class variable. Can have more than two classes.

thresh_qntl

quantile, in \((0, 1]\), of the distances from a sample to the other samples of its class that determines the bandwidth of the Gaussian kernel. Smaller values favor transitions to the nearest samples (local structure), larger values give more diverse transitions. Default is 0.1.

ovRate

Oversampling rate. Class \(j\) receives round(ovRate * (n_max - n_j)) synthetic samples, where n_max is the size of the largest class (halves are rounded up). Default is 1 meaning full balance. A vector with one value per class is also accepted.

tol

convergence threshold of the Sinkhorn normalization. Default is 1e-4.

max_iter

maximum number of Sinkhorn iterations. Default is 1000.

...

not used.

Value

a list with resampled dataset.

x_new

Resampled feature matrix.

y_new

Resampled target variable.

x_syn

Generated synthetic feature data.

y_syn

Generated synthetic label data.

converged

Logical vector (one element per class) telling whether the Sinkhorn normalization converged within max_iter.

Details

Year: 2025.

MCSMOTE (Saglam & Cengiz, 2025) models oversampling as a Markov chain over the samples of the class to be oversampled. A Gaussian kernel similarity matrix with sample specific bandwidths is calculated from the pairwise distances, where the bandwidth of sample \(i\) is the thresh_qntl quantile of its distances. The matrix is turned into a doubly stochastic transition matrix by Sinkhorn-Knopp normalization. A synthetic sample is generated by randomly selecting an initial sample, drawing a target sample with the transition probabilities of the initial sample, and interpolating between the two with a uniform random coefficient.

Can work with classes more than 2. Each class smaller than the largest one is oversampled using only its own samples.

References

Saglam, F., & Cengiz, M. A. (2025). MCSMOTE: A transition matrix-driven oversampling technique for class imbalance. Applied Soft Computing, 185, 113906.

Author

Fatih Saglam, saglamf89@gmail.com

Examples


set.seed(1)
x <- rbind(matrix(rnorm(2000, 3, 1), ncol = 2, nrow = 1000),
           matrix(rnorm(100, 5, 1), ncol = 2, nrow = 50))
y <- as.factor(c(rep("negative", 1000), rep("positive", 50)))

plot(x, col = y)


# resampling
m <- MCSMOTE(x = x, y = y, thresh_qntl = 0.05)

plot(m$x_new, col = m$y_new)