Skip to main content
. 2022 Dec 21;23(1):40. doi: 10.3390/s23010040
Algorithm 1: SMOTE

Input: M (number of samples in the minority class), N (% ratio of synthetic minority samples for class balancing), K (number of nearest neighbors), ssyn synthetic instance;

Choose randomly a subset S of the minority class data of size S=N100M (synthetic samples in the minority class) such that the class labels are uniformly distributed;

for allsiSdo

 (1) Find the K nearest neighbors;

 (2) Randomly select one of KNNs, called s^i;

 (3) Calculate the distance di,k=s^isi between the randomly selected NN s^i and the instance si;

 (4) The new synthetic instance is generated as ssyn=si+δdi,k (where δ=rand(0,1) is a random number between 0 and 1);

end for

Repeat steps number 2–4 until the desired proportion of minority class is met.