Commit 8d6c9c18 authored by Your Name's avatar Your Name

change train.py

parent 4d666db1
......@@ -449,14 +449,14 @@ if __name__ == "__main__":
path = "hdfs://172.16.32.4:8020/strategy/esmm/"
tf.logging.set_verbosity(tf.logging.INFO)
host='172.16.40.158'
port=4000
user='root'
password='3SYz54LS9#^9sBvC'
db='jerry_test'
engine = create_engine(str(r"mysql+pymysql://%s:" + '%s' + "@%s:%s/%s") % (user, password, host, port, db))
con = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test', charset = 'utf8')
cur = con.cursor()
# host='172.16.40.158'
# port=4000
# user='root'
# password='3SYz54LS9#^9sBvC'
# db='jerry_test'
# engine = create_engine(str(r"mysql+pymysql://%s:" + '%s' + "@%s:%s/%s") % (user, password, host, port, db))
# con = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test', charset = 'utf8')
# cur = con.cursor()
if FLAGS.task_type == 'train':
print("train task")
......@@ -470,14 +470,16 @@ if __name__ == "__main__":
result = main(te_files)
df = df_sort(result,queue_name)
# df2 = df.drop("time",1)
df.to_sql('esmm_device_diary_queue_nearby', con=engine, if_exists='replace', index=False, chunksize=8000)
df.to_csv(FLAGS.local_dir + "nearby_queue.csv", header=True, index=False)
# df.to_sql('esmm_device_diary_queue_nearby', con=engine, if_exists='replace', index=False, chunksize=8000)
if queue_name == "native_queue":
print(queue_name + " task")
result = main(te_files)
df_native = df_sort(result,queue_name)
nearby_sql = "select device_id,city_id,nearby_queue from esmm_device_diary_queue_nearby"
cur.execute(nearby_sql)
df_nearby = cur.fetchall()
# nearby_sql = "select device_id,city_id,nearby_queue from esmm_device_diary_queue_nearby"
# cur.execute(nearby_sql)
# df_nearby = cur.fetchall()
df_nearby = pd.read_csv(FLAGS.local_dir + "nearby_queue.csv")
#merge
df_merge = pd.merge(df_native,df_nearby, on=['device_id', 'city_id'], how='outer').fillna("")
df_merge['device_id'] = df_merge['device_id'].astype(str)
......
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