-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyeast_opt_model.py
96 lines (83 loc) · 3.04 KB
/
yeast_opt_model.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import pandas as pd
method = ['bbgp', 'gcmh', 'ks']
shape = ['full','tied', ]
kmeans = ['elkan']
opt1 = [[6,14,13,16,13,12],
[6,15,11,11,12,13],
[6,15,13,14,12,13],
[6,13,12,13,10,11],
[6,15,11,10,11,12],
[7,14,11,12,11,11],
[7,15,10,12,11,13],
[7,14,10,14,11,11],
[9,12,9,14,11,13],
[6,14,12,11,12,12],
[6,13,11,12,10,12],
[6,13,11,14,12,13],
[6,14,11,12,12,13],
[7,14,10,11,11,12],
[6,14,10,14,12,12],
[7,14,15,11,11,12]]
opt2 = [[8,9,8],
[8,9,7],
[8,9,8],
[8,8,8],
[8,9,8],
[8,9,7],
[8,9,7],
[8,9,8],
[8,8,7],
[8,9,7],
[9,9,7],
[8,9,8],
[8,9,7],
[8,7,8],
[8,9,7],
[8,9,7]]
for i in range(1, 17):
labels = pd.DataFrame()
a = 0
b = 0
for m in method:
for s in shape:
PATH = '../LTE_CLUSTER/cluster/em_1d_' + m + '_' + s + str(i) +'/em_' + str(opt1[i-1][a]) + '.csv'
print(PATH)
preLabel = pd.read_csv(PATH, ',')
if( m == 'ks'):
class_max = preLabel.groupby(['label'])[m.upper()].max()
class_max = class_max.sort_values(ascending=False).tolist()
j = 1
for cut in class_max:
preLabel.loc[preLabel[m.upper()] <= cut, 'label'] = (opt1[i-1][a]+1)-j
j += 1
else:
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'] = (opt1[i-1][a]+1)-j
j += 1
labels['pos'] = preLabel['POS']
labels[m+s] = preLabel['label']
a += 1
for k in kmeans:
PATH = '../LTE_CLUSTER/cluster/kmeans_1d_' + m + '_' + k + str(i) +'/Kmeans' + str(opt2[i-1][b]) + '.csv'
preLabel = pd.read_csv(PATH, ',')
if( m == 'ks'):
class_max = preLabel.groupby(['label'])[m.upper()].max()
class_max = class_max.sort_values(ascending=False).tolist()
j = 1
for cut in class_max:
preLabel.loc[preLabel[m.upper()] <= cut, 'label'] = (opt2[i-1][b]+1)-j
j += 1
else:
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'] = (opt2[i-1][b]+1)-j
j += 1
labels['pos'] = preLabel['POS']
labels['Km' + m+k] = preLabel['label']
b+=1
labels.to_csv('../LTE_CLUSTER/merging_' + str(i) + 'OPT.csv', index= False)