0% found this document useful (0 votes)
3 views2 pages

SMOTE Sample Calculation Guide

The document describes the process of calculating synthetic minority oversampling technique (SMOTE) samples. It provides the number of samples needed, generates random sample indices and step sizes. It then uses the sample indices, rows and columns of the nearest neighbor data, and step sizes to calculate new synthetic samples. Each new sample is generated by randomly perturbing an existing minority class sample and its nearest neighbors.

Uploaded by

Hsu Let Yee Hnin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

SMOTE Sample Calculation Guide

The document describes the process of calculating synthetic minority oversampling technique (SMOTE) samples. It provides the number of samples needed, generates random sample indices and step sizes. It then uses the sample indices, rows and columns of the nearest neighbor data, and step sizes to calculate new synthetic samples. Each new sample is generated by randomly perturbing an existing minority class sample and its nearest neighbors.

Uploaded by

Hsu Let Yee Hnin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SMOTE Samples Calculation

random_state = 1
y_type = 1(churn)
nn_data = X_class[y==1]
nn_num = [[2, 3, 1, 5, 4],
[2, 3, 0, 5, 4],
[3, 0, 1, 5, 4],
[2, 0, 1, 5, 4],
[2, 0, 3, 1, 5],
[2, 0, 3, 1, 4]]

n_samples = 38 (no_y=0 data – no_y=1 data)=44-6

step_size=1.0

Samples = random(0,len(nn_num),38)
Samples = [ 5 11 12 8 9 11 5 15 0 16 1 12 7 13 28 6 25 18 20 5 18 20 11 28
10 28 29 14 18 4 23 23 9 17 23 0 22 13]

steps = 1.0 * random_state.uniform(0,38)


1
uniform(a,b)= b−a

steps [0.2609, 0.231, 0.5334, 0.9499, 0.493, 0.5406, 0.7654, 0.0453, 0.139,
0.7924, 0.0298, 0.8831,
0.5407, 0.4479, 0.8921, 0.3775, 0.5384, 0.6522, 0.3612, 0.571, 0.6378, 0.1263,
0.6902, 0.6477,
0.3539, 0.7632, 0.3565, 0.7527, 0.8813, 0.0116, 0.4981, 0.0737, 0.7869, 0.064,
0.3553, 0.9418,
0.3798, 0.7629]

rows = floor_divide(samples, nn_num.shape[1])

rows = [1 2 2 1 1 2 1 3 0 3 0 2 1 2 5 1 5 3 4 1 3 4 2 5 2 5 5 2 3 0 4 4 1 3 4 0 4 2]

cols = mod(samples, nn_num.shape[1])


[0 1 2 3 4 1 0 0 0 1 1 2 2 3 3 1 0 3 0 0 3 0 1 3 0 3 4 4 3 4 3 3 4 2 3 0 2
3]

For i in samples,Rows,Cols,Steps:
X_new[i] = nn_data[row] - step * (nn_data[row] - nn_data[nn_num[row,
col]])
y_new = [Link]([y_type] * len(X_new))

X-new = -0.54403 – 0.2609 *(-0.54033-nn_data[nn_num[1,0])


= -0.54033 – 0.2609 (-0.54033-nn_data[2])
= -0.54033 – 0.2609 (-0.54033 – 0.4669)
= -0.2775
X_new&y_new

You might also like