Commit f0746c05 authored by 张彦钊's avatar 张彦钊

Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline

增加数据库捕捉异
parents 76c111ee 6e209881
from utils import con_sql,tuple2dict,get_yesterday_date
# -*- coding: UTF-8 -*-
from utils import con_sql,get_yesterday_date
import time
OUTPUT_PATH = "/data2/models/eda/gray_stat/"
class GrayStat(object):
def __init__(self, cid_type, uid_type, platform,ndays=get_yesterday_date()):
......@@ -55,11 +60,13 @@ class GrayStat(object):
if __name__ == '__main__':
print("开始获取ffm中的灰度非灰度比例")
start = time.time()
#1.ffm中的灰度非灰度(ios和安卓一样):
# 灰度:_6
# 非灰度:_8
result1 = []
#1.1获取ios和android平台的数据
platforms = ['ios','android']
grays = ['6','8']
for platform in platforms:
......@@ -76,6 +83,7 @@ if __name__ == '__main__':
result1[-1][5]+result1[-2][5],\
result1[-1][6]+result1[-2][6],\
round((result1[-1][5]+result1[-2][5])/(result1[-1][6]+result1[-2][6]),4)])
#1.2获取所有平台的数据
labels = ['6','8','all']
for i in range(3):
result1.append([g_class.ndays,g_class.cid_type,'all',labels[i],\
......@@ -83,8 +91,13 @@ if __name__ == '__main__':
result1[i][5]+result1[i+3][5],\
result1[i][6]+result1[i+3][6],\
round((result1[i][5]+result1[i+3][5])/(result1[i][6]+result1[i+3][6]),4)])
#1.3把一天所有的数据存入文件
output1 = OUTPUT_PATH + "gray_ffm.csv"
with open(output1,'a+') as f:
for line in result1:
line = [str(i) for i in line]
str_line = ','.join(line) + ',' + '\n'
f.write(str_line)
#2.实际中的灰度非灰度:
# ios:
......@@ -93,7 +106,9 @@ if __name__ == '__main__':
# android:
# 灰度:0|1|2|6|8
#非灰度:^01268
print("开始获取实际中的灰度非灰度比例")
result2 = []
#2.1获取ios和android平台的数据
platforms = ['ios','android']
for platform in platforms:
#TODO 对于(安卓灰度放到 0 1 2 6 8;iOS灰度保持 6 8)问题,做一个id判断即可
......@@ -114,6 +129,7 @@ if __name__ == '__main__':
result2[-1][5]+result2[-2][5],\
result2[-1][6]+result2[-2][6],\
round((result2[-1][5]+result2[-2][5])/(result2[-1][6]+result2[-2][6]),4)])
#2.2获取所有平台的数据
labels = ['gray','not gray','all']
for i in range(3):
result2.append([g_class.ndays,g_class.cid_type,'all',labels[i],\
......@@ -121,8 +137,15 @@ if __name__ == '__main__':
result2[i][5]+result2[i+3][5],\
result2[i][6]+result2[i+3][6],\
round((result2[i][5]+result2[i+3][5])/(result2[i][6]+result2[i+3][6]),4)])
#2.3把一天所有的数据写入文件
output2 = OUTPUT_PATH + "gray_all.csv"
with open(output2,'a+') as f:
for line in result2:
line = [str(i) for i in line]
str_line = ','.join(line) + ',' + '\n'
f.write(str_line)
end = time.time()
print("程序执行时间:{}s".format(end-start))
......@@ -116,7 +116,7 @@ print("done")
end = time.time()
print('程序执行时间: ',end - start)
print('程序执行时间: {}s'.format(end-start))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment