-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_relabel_1D1.py
47 lines (31 loc) · 1.33 KB
/
class_relabel_1D1.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
import pandas as pd
method = ['bbgp', 'gcmh', 'ks']
shape = ['full','tied', ]
kmeans = ['full']
for c in range(2,11):
labels = pd.DataFrame()
for m in method:
for s in shape:
PATH = './1d_cutoff/em_1d_' + m + '_' + s +'/em_' + str(c)+ '.csv'
preLabel = pd.read_csv(PATH, ',')
class_min = preLabel.groupby(['label'])[m.upper()].min()
class_min = class_min.sort_values(ascending=True).tolist()
j = 1
for cut in class_min:
preLabel.loc[preLabel[m.upper()] >= cut, 'label'] = (c+1)-j
j += 1
labels['pos'] = preLabel['2L_POS']
labels[m+s] = preLabel['label']
for k in kmeans:
PATH = './1d_cutoff/kmeans_1d_' + m + '_' + k + '/Kmeans' + str(c) + '.csv'
preLabel = pd.read_csv(PATH, ',')
class_min = preLabel.groupby(['label'])[m.upper()].min()
class_min = class_min.sort_values(ascending=True).tolist()
j=1
for cut in class_min:
preLabel.loc[preLabel[m.upper()] >= cut, 'label'] = (c+1)-j
j += 1
labels['pos'] = preLabel['2L_POS']
labels['Km' + m+k] = preLabel['label']
print(c)
labels.to_csv('./1d_cutoff/merging_em' + str(c) + '.csv', index= False)