Skip to main content
. 2023 Nov 27;9:e1580. doi: 10.7717/peerj-cs.1580
Algorithm SMOTE (S, M, A)
Input:
A= Number of nearest neighbors
M= Number of samples from minority classes
S= Amount of SMOTE S %
Output: (S100) * M Samples of synthetic minority classes
(“Identify minority class samples in the data set. If S is less than 100%, randomize the
minority class samples since only a random percentage of them will be SMOTE”)
ifS <100
Then determine the minority class sample M randomly
M = (S100) ∗M
S= 100
endif
S= (int)(S100) (“determine the number of SMOTE samples assuming that the number
is an integer with a multiple of 100”)
A= Number of nearest neighbors
numattrs= Number of attributes
Sample [ ] [ ]: is a number of original samples in the form of Arrays from the minority
class
newindex: the resulting number of samples is calculated by initializing to 0
Synthetic [ ] [ ]: Array for synthetic samples (“only calculates the number of nearest
neighbors of A for each sample”)
for i← 1 toM
nearest neighbor i is calculated using A then store index into array n
Populate (S, i, n array)
endfor
Populate (S, i, nnarray) (“this is a manufacturing function with synthetic samples”)
whileS≠ 0
select data one from “A” for nearest neighbor “i” by randomly selecting 1 and A
for attr← 1 tonumattrs
Compute: dif=Sample [nnarray [nn ]] [attr ] −Sample [i ][attr ]