-
Notifications
You must be signed in to change notification settings - Fork 0
/
TraditionalBackbone.py
54 lines (48 loc) · 1.31 KB
/
TraditionalBackbone.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Domain generation
s = 1
c = 1
while s <= 5:
c = 1
while c <= 5:
num_intervals = 2**c
i = 1
while i <=5 :
gap_init = 0
gap = float(1/num_intervals)
gap_last = gap
x = []
y = []
cls = '+'
cnt = 0
print('Size: ',s,' Complexity: ',c,' Imbalance: ',i)
while gap_init < 1:
if cls == '+':
examples = 0
print('1 class: ',ceil(((5000/32)*2**s)/2**c))
while examples < ceil(((5000/32)*2**s)/2**c):
x.append(random.uniform(gap_init,gap_last))
y.append(1)
examples+=1
if cls == '-':
examples = 0
print('0 class: ',ceil((((5000/32)*2**s)/2**c)/(32/2**i)))
while examples < ceil((((5000/32)*2**s)/2**c)/(32/2**i)):
x.append(random.uniform(gap_init,gap_last))
y.append(0)
examples+=1
cnt += 1
print('cnt%2: ',cnt%2)
if cnt%2 == 0:
cls = '+'
else:
cls = '-'
gap_last += gap
gap_init += gap
df_name = '/content/'+'size'+str(s)+'_complex'+str(c)+'_imbalance'+str(i)+'.xlsx'
x=pd.DataFrame(x,columns=['X'])
y=pd.DataFrame(y,columns=['Y'])
df=pd.concat([x,y],axis=1)
df.to_excel(df_name)
i+=1
c+=1
s+=1