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

修改测试文件

parent 0cea747f
...@@ -38,7 +38,7 @@ def feature_engineer(): ...@@ -38,7 +38,7 @@ def feature_engineer():
validate_date = con_sql(db, sql)[0].values.tolist()[0] validate_date = con_sql(db, sql)[0].values.tolist()[0]
print("validate_date:" + validate_date) print("validate_date:" + validate_date)
temp = datetime.datetime.strptime(validate_date, "%Y-%m-%d") temp = datetime.datetime.strptime(validate_date, "%Y-%m-%d")
start = (temp - datetime.timedelta(days=100)).strftime("%Y-%m-%d") start = (temp - datetime.timedelta(days=3)).strftime("%Y-%m-%d")
print(start) print(start)
sql = "select e.y,e.z,e.stat_date,e.ucity_id,feat.level2_ids,e.ccity_name,u.device_type,u.manufacturer," \ sql = "select e.y,e.z,e.stat_date,e.ucity_id,feat.level2_ids,e.ccity_name,u.device_type,u.manufacturer," \
...@@ -107,8 +107,14 @@ def feature_engineer(): ...@@ -107,8 +107,14 @@ def feature_engineer():
value_map[x[13]], value_map[x[14]], value_map[x[15]], value_map[x[16]], value_map[x[13]], value_map[x[14]], value_map[x[15]], value_map[x[16]],
value_map[x[17]], x[18], x[19])) value_map[x[17]], x[18], x[19]))
spark.createDataFrame(test).write.format("avro").save(path="/recommend/va", mode="overwrite") spark.createDataFrame(test).toDF("app_list","level2_ids","level3_ids","stat_date","ucity_id", "ccity_name", "device_type", "manufacturer",
spark.createDataFrame(train).write.format("avro").save(path="/recommend/tr", mode="overwrite") "channel", "top", "time", "hospital_id","treatment_method", "price_min",
"price_max", "treatment_time","maintain_time", "recover_time","y","z")\
.write.format("avro").save(path="/recommend/va", mode="overwrite")
spark.createDataFrame(train).toDF("app_list","level2_ids","level3_ids","stat_date","ucity_id", "ccity_name", "device_type", "manufacturer",
"channel", "top", "time", "hospital_id","treatment_method", "price_min",
"price_max", "treatment_time","maintain_time", "recover_time","y","z")\
.write.format("avro").save(path="/recommend/tr", mode="overwrite")
print("done") print("done")
rdd.unpersist() rdd.unpersist()
...@@ -231,10 +237,10 @@ if __name__ == '__main__': ...@@ -231,10 +237,10 @@ if __name__ == '__main__':
ti = pti.TiContext(spark) ti = pti.TiContext(spark)
ti.tidbMapDatabase("jerry_test") ti.tidbMapDatabase("jerry_test")
spark.sparkContext.setLogLevel("WARN") spark.sparkContext.setLogLevel("WARN")
# validate_date, value_map, app_list_map, leve2_map, leve3_map = feature_engineer() validate_date, value_map, app_list_map, leve2_map, leve3_map = feature_engineer()
# get_predict(validate_date, value_map, app_list_map, leve2_map, leve3_map) get_predict(validate_date, value_map, app_list_map, leve2_map, leve3_map)
test()
......
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