Sfoglia il codice sorgente

add pymssql in kpi.py

master
Jeong Geol Kim 4 anni fa
parent
commit
022cb6c65e
1 ha cambiato i file con 31 aggiunte e 2 eliminazioni
  1. 31
    2
      kpi.py

+ 31
- 2
kpi.py Vedi File

3
 import math
3
 import math
4
 import sys
4
 import sys
5
 import numpy as np
5
 import numpy as np
6
+from numpy.lib.function_base import append
6
 import pandas as pd
7
 import pandas as pd
7
 from pandas import DataFrame as df
8
 from pandas import DataFrame as df
8
 from sklearn.cluster import DBSCAN
9
 from sklearn.cluster import DBSCAN
10
+import pymssql
9
 #import matplotlib.pyplot as plt
11
 #import matplotlib.pyplot as plt
10
 
12
 
11
 
13
 
13
 file_path = '/hdd/' + ssd_dir[5:]
15
 file_path = '/hdd/' + ssd_dir[5:]
14
 count = 1
16
 count = 1
15
 
17
 
18
+def put_kpi_to_db(kpi):
19
+    conn = pymssql.connect(server='52.231.39.219',port=1433, user='mc365', password='tkadbrdhmc1!', database='master')
20
+    
21
+    cursor = conn.cursor()
22
+    cursor.execute("INSERT INTO tsfmc_mailsystem.dbo.KPI(surgeryID, totalStrokeCount, totalStrokeVelocity, totalStrokeDepth, upDownTotalStrokeCount, upDownTotalStrokeVelocity, upDownTotalStrokeDepth, leftRightTotalStrokeCount, leftRightTotalStrokeVelocity, leftRightTotalStrokeDepth, quadrant1TotalStrokeCount, quadrant1TotalStrokeVelocity, quadrant1TotalStrokeDepth, quadrant2TotalStrokeCount, quadrant2TotalStrokeVelocity, quadrant2TotalStrokeDepth, quadrant3TotalStrokeCount, quadrant3TotalStrokeVelocity, quadrant3TotalStrokeDepth, quadrant4TotalStrokeCount, quadrant4TotalStrokeVelocity, quadrant4TotalStrokeDepth) VALUES ("+str(kpi[0])+", "+kpi[1]+", "+kpi[2]+", "+kpi[3]+", "+kpi[4]+", "+kpi[5]+", "+kpi[6]+", "+kpi[7]+", "+kpi[8]+", "+kpi[9]+", "+kpi[10]+", "+kpi[11]+", "+kpi[12]+", "+kpi[13]+", "+kpi[14]+", "+kpi[15]+", "+kpi[16]+", "+kpi[17]+", "+kpi[18]+", "+kpi[19]+", "+kpi[20]+", "+kpi[21]+")")  
23
+    conn.commit()
24
+    conn.close()
25
+
26
+
16
 def get_quad(df):
27
 def get_quad(df):
17
     if df['x'] >= 0 and df['y'] >= 0:
28
     if df['x'] >= 0 and df['y'] >= 0:
18
         return 1
29
         return 1
147
     kpi['qaud2_c'] = len(quad2_c)
158
     kpi['qaud2_c'] = len(quad2_c)
148
     kpi['qaud3_c'] = len(quad3_c)
159
     kpi['qaud3_c'] = len(quad3_c)
149
     kpi['qaud4_c'] = len(quad4_c)
160
     kpi['qaud4_c'] = len(quad4_c)
161
+    #FIXME: this values are huristic value. please change this values after research
150
     kpi['qaud1_s'] = quad1_c['sqrt'].mean() / 30
162
     kpi['qaud1_s'] = quad1_c['sqrt'].mean() / 30
151
     kpi['qaud2_s'] = quad2_c['sqrt'].mean() / 30
163
     kpi['qaud2_s'] = quad2_c['sqrt'].mean() / 30
152
     kpi['qaud3_s'] = quad3_c['sqrt'].mean() / 30
164
     kpi['qaud3_s'] = quad3_c['sqrt'].mean() / 30
190
     #lr_d_rate =
202
     #lr_d_rate =
191
     val_list.append("{:.4f}".format((kpi_1['depth'][2] + kpi_1['depth'][3] - kpi_1['depth'][0] - kpi_1['depth'][1])/2))
203
     val_list.append("{:.4f}".format((kpi_1['depth'][2] + kpi_1['depth'][3] - kpi_1['depth'][0] - kpi_1['depth'][1])/2))
192
 
204
 
205
+    #q1 s, v, d
206
+    val_list.append(len(quad1_c))
207
+    val_list.append(quad1_c['sqrt'].mean() / 30)
208
+    val_list.append(quad1_c['sqrt'].mean() / 45)
209
+    val_list.append(len(quad2_c))
210
+    val_list.append(quad2_c['sqrt'].mean() / 30)
211
+    val_list.append(quad2_c['sqrt'].mean() / 45)
212
+    val_list.append(len(quad3_c))
213
+    val_list.append(quad3_c['sqrt'].mean() / 30)
214
+    val_list.append(quad3_c['sqrt'].mean() / 45)
215
+    val_list.append(len(quad4_c))
216
+    val_list.append(quad4_c['sqrt'].mean() / 30)
217
+    val_list.append(quad4_c['sqrt'].mean() / 45)
218
+
193
 
219
 
194
-    #print(val_list)
195
 
220
 
196
 
221
 
222
+    return val_list
197
 
223
 
224
+    #print(val_list)
198
 
225
 
199
 
226
 
200
 
227
 
201
-dist()
228
+if __name__ == "__main__":
229
+    kpi = dist()
230
+    put_kpi_to_db(kpi)

Loading…
Annulla
Salva