-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_data_annotate.py
212 lines (168 loc) · 10.9 KB
/
prepare_data_annotate.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import warnings
import pandas as pd
from rdflib import Graph, URIRef, BNode
from rdflib.namespace import RDF
#from calc_gaps_slopes import gap_calc,trend_calc,monotonic_pred,mod_collector
#from insert_annotate import insert_annotate
from gap_annotate import goal_gap_annotate,peer_gap_annotate,top_10_gap_annotate,top_25_gap_annotate
from acheivement_loss_annotate import goal_acheivementloss_annotate,peer_acheivementloss_annotate,top_10_acheivementloss_annotate,top_25_acheivementloss_annotate
from consecutive_gap_annotate import goal_consecutive_annotate,peer_consecutive_annotate,top_10_consecutive_annotate,top_25_consecutive_annotate
from trend_annotate import trend_annotate
from monotinicity_annotate import monotonic_annotate
warnings.filterwarnings("ignore")
class Prepare_data_annotate:
global latest_measure_df
latest_measure_df = pd.DataFrame()
measure_data1 = pd.DataFrame()
measure_data2 = pd.DataFrame()
def __init__(self,input_graph:Graph,performance_data:pd.DataFrame,comparison_values:pd.DataFrame):
self.performance_data=performance_data
self.comparison_vaues=comparison_values
performance_rate =[]
for rowIndex, row in self.performance_data.iterrows():
if (row['passed_count']==0 and row['denominator']==0):
performance_rate.append(0.0)
else:
performance_rate.append(row['passed_count']/row['denominator'])
self.performance_data['Performance_Rate']=performance_rate
self.performance_data['peer_average_comparator']=self.performance_data['peer_average_comparator']/100
self.performance_data['peer_90th_percentile_benchmark']=self.performance_data['peer_90th_percentile_benchmark']/100
self.performance_data['peer_75th_percentile_benchmark']=self.performance_data['peer_75th_percentile_benchmark']/100
self.performance_data['month'] = pd.to_datetime(self.performance_data['month'])
self.performance_data[['measure']] = self.performance_data[['measure']].astype(str)
self.comparison_vaues[['measure']] = self.comparison_vaues[['measure']].astype(str)
self.performance_data.measure = self.performance_data.measure.str.encode('utf-8')
self.comparison_vaues.measure = self.comparison_vaues.measure.str.encode('utf-8')
self.data=self.performance_data.merge(self.comparison_vaues, how='outer', on=['measure'])
self.data["measure"]=self.data["measure"].str.decode(encoding="UTF-8")
self.data[['peer_average_comparator']] = self.data[['peer_average_comparator']].astype(float)
self.data[['peer_90th_percentile_benchmark']] = self.data[['peer_90th_percentile_benchmark']].astype(float)
self.data[['peer_75th_percentile_benchmark']] = self.data[['peer_75th_percentile_benchmark']].astype(float)
self.data[['Performance_Rate']] = self.data[['Performance_Rate']].astype(float)
self.data[['goal_comparison_value']] = self.data[['goal_comparison_value']].astype(float)
idx= self.data.groupby(['measure'])['month'].transform(max) == self.data['month']
self.latest_measure = self.data[idx]
#self.data.to_csv("final_df1.csv")
self.input_graph=input_graph
def prepare_data_measure_name(self,measure_name:str,**goal_dicts):
global measure_data1
measure_data1 = self.latest_measure[self.latest_measure['measure'] == measure_name]
global measure_data2
measure_data2 = self.data[self.data['measure'] == measure_name]
ac=BNode(measure_name)
global comparator_bnode
comparator_bnode=goal_dicts.get(ac)
return measure_data1,measure_data2,comparator_bnode
#print(measure_data1)
#self.measure_data2.to_csv("final_df1.csv")
# print(self.dict)
# #
def insert_annotate(self,a):
s12 = URIRef('http://example.com/app#display-lab')
p12=URIRef('http://example.com/slowmo#IsAboutPerformer')
o12=BNode('p1')
a.add((s12,p12,o12))
s13=BNode('p1')
p13=RDF.type
o13=URIRef("http://purl.obolibrary.org/obo/psdo_0000085")
a.add((s13,p13,o13))
return a,s13
def gaol_gap_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = goal_gap_annotate(self.a,self.s13,measure_data1,comparator_bnode)
return a
def peer_gap_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = peer_gap_annotate(self.a,self.s13,measure_data1,comparator_bnode)
return a
def top_10_gap_annotate(self,measure_name:str,**top_10_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**top_10_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_10_gap_annotate(self.a,self.s13,measure_data1,comparator_bnode)
return a
def top_25_gap_annotate(self,measure_name:str,**top_10_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**top_10_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_25_gap_annotate(self.a,self.s13,measure_data1,comparator_bnode)
return a
def goal_trend_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = trend_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def peer_trend_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = trend_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_10_trend_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = trend_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_25_trend_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = trend_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def goal_acheivement_loss_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = goal_acheivementloss_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def peer_acheivement_loss_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = peer_acheivementloss_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_10_acheivement_loss_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_10_acheivementloss_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_25_acheivement_loss_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_25_acheivementloss_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def goalconsecutive_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = goal_consecutive_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def peerconsecutive_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = peer_consecutive_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_10consecutive_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_10_consecutive_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_25consecutive_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = top_25_consecutive_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def goal_monotonicity_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = monotonic_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def peer_monotonicity_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = monotonic_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a
def top_10_monotonicity_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = monotonic_annotate(self.a,self.s13,measure_data2,comparator_bnode)
def top_25_monotonicity_annotate(self,measure_name:str,**goal_dicts):
measure_data1,measure_data2,comparator_bnode=self.prepare_data_measure_name(measure_name,**goal_dicts)
self.a,self.s13=self.insert_annotate(self.input_graph)
a = monotonic_annotate(self.a,self.s13,measure_data2,comparator_bnode)
return a