Explorar el Código

add pymssql in kpi.py

master
Jeong Geol Kim hace 4 años
padre
commit
022cb6c65e
Se han modificado 1 ficheros con 31 adiciones y 2 borrados
  1. 31
    2
      kpi.py

+ 31
- 2
kpi.py Ver fichero

@@ -3,9 +3,11 @@ import time
3 3
 import math
4 4
 import sys
5 5
 import numpy as np
6
+from numpy.lib.function_base import append
6 7
 import pandas as pd
7 8
 from pandas import DataFrame as df
8 9
 from sklearn.cluster import DBSCAN
10
+import pymssql
9 11
 #import matplotlib.pyplot as plt
10 12
 
11 13
 
@@ -13,6 +15,15 @@ ssd_dir = str(sys.argv[1])
13 15
 file_path = '/hdd/' + ssd_dir[5:]
14 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 27
 def get_quad(df):
17 28
     if df['x'] >= 0 and df['y'] >= 0:
18 29
         return 1
@@ -147,6 +158,7 @@ def dist():
147 158
     kpi['qaud2_c'] = len(quad2_c)
148 159
     kpi['qaud3_c'] = len(quad3_c)
149 160
     kpi['qaud4_c'] = len(quad4_c)
161
+    #FIXME: this values are huristic value. please change this values after research
150 162
     kpi['qaud1_s'] = quad1_c['sqrt'].mean() / 30
151 163
     kpi['qaud2_s'] = quad2_c['sqrt'].mean() / 30
152 164
     kpi['qaud3_s'] = quad3_c['sqrt'].mean() / 30
@@ -190,12 +202,29 @@ def dist():
190 202
     #lr_d_rate =
191 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…
Cancelar
Guardar