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

change test file

parent 5215db46
......@@ -71,11 +71,11 @@ def feature_engineer():
.map(lambda x: (app_list_func(x[0], app_list_map),[value_map[x[2]],value_map[x[1]]], float(x[3]),float(x[4])))
spark.createDataFrame(test).toDF("level2_ids","ids","y","z")\
.repartition(1).write.format("tfrecords").save(path=path+"va/", mode="overwrite")
.coalesce(1).write.format("tfrecords").save(path=path+"va/", mode="overwrite")
print("va write done")
spark.createDataFrame(train).toDF("level2_ids","ids","y","z") \
.repartition(1).write.format("tfrecords").save(path=path+"tr/", mode="overwrite")
.coalesce(1).write.format("tfrecords").save(path=path+"tr/", mode="overwrite")
print("done")
rdd.unpersist()
......@@ -99,13 +99,13 @@ def get_predict(date,value_map,app_list_map):
native_pre = spark.createDataFrame(rdd.filter(lambda x:x[4] == 0).map(lambda x:(x[1],x[2],x[3])))\
.toDF("city","uid","cid_id")
print("native")
native_pre.toPandas().to_csv(local_path+"native.csv", header=True)
# native_pre.toPandas().to_csv(local_path+"native.csv", header=True)
native_pre.repartition(1).write.csv(path+"native.csv", sep=',',header=True)
native_pre.coalesce(1).write.format('com.databricks.spark.csv').save(path+"hello.csv",header = 'true')
# 预测的tfrecord必须写成一个文件,这样可以摆保证顺序
spark.createDataFrame(rdd.filter(lambda x: x[4] == 0).map(lambda x: (x[0],x[5],x[6],x[7]))) \
.toDF("level2_ids","y","z","ids").repartition(1).write.format("tfrecords") \
.toDF("level2_ids","y","z","ids").coalesce(1).write.format("tfrecords") \
.save(path=path+"native/", mode="overwrite")
nearby_pre = spark.createDataFrame(rdd.filter(lambda x: x[4] == 1).map(lambda x:(x[1],x[2],x[3]))) \
......@@ -113,7 +113,7 @@ def get_predict(date,value_map,app_list_map):
print("nearby")
nearby_pre.toPandas().to_csv(local_path+"nearby.csv", header=True)
spark.createDataFrame(rdd.filter(lambda x: x[4] == 1).map(lambda x: (x[0], x[5], x[6], x[7]))) \
.toDF("level2_ids","y","z","ids").repartition(1).write.format("tfrecords") \
.toDF("level2_ids","y","z","ids").coalesce(1).write.format("tfrecords") \
.save(path=path+"nearby/", mode="overwrite")
rdd.unpersist()
......
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