File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
imblearn/over_sampling/tests Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ from collections import Counter
2+
3+ import numpy as np
4+ import pytest
5+
6+ from imblearn .over_sampling import SMOTEN
7+
8+
9+ @pytest .fixture
10+ def data ():
11+ rng = np .random .RandomState (0 )
12+
13+ feature_1 = ["A" ] * 10 + ["B" ] * 20 + ["C" ] * 30
14+ feature_2 = ["A" ] * 40 + ["B" ] * 20
15+ feature_3 = ["A" ] * 20 + ["B" ] * 20 + ["C" ] * 10 + ["D" ] * 10
16+ X = np .array ([feature_1 , feature_2 , feature_3 ], dtype = object ).T
17+ rng .shuffle (X )
18+ y = np .array ([0 ] * 20 + [1 ] * 40 , dtype = np .int32 )
19+ y_labels = np .array (["not apple" , "apple" ], dtype = object )
20+ y = y_labels [y ]
21+ return X , y
22+
23+
24+ def test_smoten (data ):
25+ X , y = data
26+ print (X , y )
27+ sampler = SMOTEN (random_state = 0 )
28+ X_res , y_res = sampler .fit_resample (X , y )
29+ print (X_res , y_res )
30+ print (Counter (y_res ))
You can’t perform that action at this time.
0 commit comments