Commit 2c1f7d0d authored by 张彦钊's avatar 张彦钊

change eda

parent 2c4c9641
...@@ -17,7 +17,7 @@ def con_sql(db, sql): ...@@ -17,7 +17,7 @@ def con_sql(db, sql):
def test(days): def test(days):
start = (temp - datetime.timedelta(days)).strftime("%Y-%m-%d") start = (temp - datetime.timedelta(days)).strftime("%Y-%m-%d")
print(start) print(start)
sql = "select (select count(*) from train_data where stat_date = '{}' and y = 0)/(select count(*) " \ sql = "select (select count(*) from esmm_train_data where stat_date = '{}' and y = 0)/(select count(*) " \
"from train_data where stat_date = '{}' and z = 1)".format(start,start) "from train_data where stat_date = '{}' and z = 1)".format(start,start)
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test') db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
exp = con_sql(db, sql) exp = con_sql(db, sql)
...@@ -31,7 +31,7 @@ def test(days): ...@@ -31,7 +31,7 @@ def test(days):
if __name__ == "__main__": if __name__ == "__main__":
temp = datetime.datetime.strptime("2019-03-14", "%Y-%m-%d") temp = datetime.datetime.strptime("2019-03-14", "%Y-%m-%d")
DIRECTORY_PATH = "/home/gmuser/" DIRECTORY_PATH = "/home/gmuser/"
output_path = DIRECTORY_PATH + "eda.csv" output_path = DIRECTORY_PATH + "esmm_train_eda.csv"
for i in range(1,41): for i in range(1,41):
a,b,c = test(i) a,b,c = test(i)
with open(output_path, 'a+') as f: with open(output_path, 'a+') as f:
......
...@@ -115,7 +115,7 @@ def get_predict(date,value_map): ...@@ -115,7 +115,7 @@ def get_predict(date,value_map):
"from esmm_pre_data e left join user_feature u on e.device_id = u.device_id " \ "from esmm_pre_data e left join user_feature u on e.device_id = u.device_id " \
"left join cid_type_top c on e.device_id = c.device_id " \ "left join cid_type_top c on e.device_id = c.device_id " \
"left join cid_level2 cl on e.cid_id = cl.cid " \ "left join cid_level2 cl on e.cid_id = cl.cid " \
"left join cid_time_cut cut on e.cid_id = cut.cid" "left join cid_time_cut cut on e.cid_id = cut.cid limit 6"
df = con_sql(db, sql) df = con_sql(db, sql)
df = df.rename(columns={0: "y", 1: "z", 2: "label", 3: "ucity_id", 4: "clevel1_id", 5: "ccity_name", df = df.rename(columns={0: "y", 1: "z", 2: "label", 3: "ucity_id", 4: "clevel1_id", 5: "ccity_name",
6: "device_type", 7: "manufacturer", 8: "channel", 9: "top", 10: "l1",11:"l2", 6: "device_type", 7: "manufacturer", 8: "channel", 9: "top", 10: "l1",11:"l2",
......
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