Commit d3f7206c authored by 赵威's avatar 赵威

update trace price type

parent 2817f05c
...@@ -174,7 +174,11 @@ _categorical_columns = [ ...@@ -174,7 +174,11 @@ _categorical_columns = [
"click_diary_id3", "click_diary_id3",
"click_diary_id4", "click_diary_id4",
"click_diary_id5", "click_diary_id5",
"service_id",
"service_city", "service_city",
"recommend_service_id",
"recommend_service_city",
"recommend_service_price",
"device_fd2", "device_fd2",
"device_sd2", "device_sd2",
"device_fs2", "device_fs2",
......
...@@ -129,9 +129,13 @@ DIARY_COLUMNS = [ ...@@ -129,9 +129,13 @@ DIARY_COLUMNS = [
"business_second_skip_num", "business_second_skip_num",
"effect_second_skip_rate", "effect_second_skip_rate",
"business_second_skip_rate", "business_second_skip_rate",
"service_id",
"service_price", "service_price",
"service_sold_num", "service_sold_num",
"service_city", "service_city",
"recommend_service_id",
"recommend_service_city",
"recommend_service_price",
] ]
INT_COLUMNS = [ INT_COLUMNS = [
"active_days", "active_days",
...@@ -302,7 +306,11 @@ CATEGORICAL_COLUMNS = [ ...@@ -302,7 +306,11 @@ CATEGORICAL_COLUMNS = [
"click_diary_id4", "click_diary_id4",
"click_diary_id5", "click_diary_id5",
"is_related_service", "is_related_service",
"service_id",
"service_city", "service_city",
"recommend_service_id",
"recommend_service_city",
"recommend_service_price",
"device_fd2", "device_fd2",
"device_sd2", "device_sd2",
"device_fs2", "device_fs2",
...@@ -415,7 +423,14 @@ def diary_feature_engineering(df): ...@@ -415,7 +423,14 @@ def diary_feature_engineering(df):
diary_df["is_have_reply"] = diary_df["is_have_reply"].astype(int) diary_df["is_have_reply"] = diary_df["is_have_reply"].astype(int)
diary_df["is_related_service"] = diary_df["is_related_service"].astype(int) diary_df["is_related_service"] = diary_df["is_related_service"].astype(int)
diary_df["service_id"] = diary_df["service_id"].astype(str)
diary_df["recommend_service_id"] = diary_df["recommend_service_id"].astype(str)
diary_df["recommend_service_price"] = diary_df["recommend_service_price"].astype(str)
diary_df["service_id"] = diary_df["service_city"].fillna("-1")
diary_df["service_city"] = diary_df["service_city"].fillna("") diary_df["service_city"] = diary_df["service_city"].fillna("")
diary_df["recommend_service_id"] = diary_df["recommend_service_id"].fillna("-1")
diary_df["recommend_service_city"] = diary_df["recommend_service_city"].fillna("")
diary_df = diary_df[DIARY_COLUMNS] diary_df = diary_df[DIARY_COLUMNS]
......
...@@ -407,13 +407,14 @@ def tractate_feature_engineering(tractate_df): ...@@ -407,13 +407,14 @@ def tractate_feature_engineering(tractate_df):
df["is_have_pure_reply"] = df["is_have_pure_reply"].astype(int) df["is_have_pure_reply"] = df["is_have_pure_reply"].astype(int)
df["is_have_reply"] = df["is_have_reply"].astype(int) df["is_have_reply"] = df["is_have_reply"].astype(int)
df["show_tag_id"] = df["show_tag_id"].astype(str) df["show_tag_id"] = df["show_tag_id"].astype(str)
df["service_id"] = df["service_id"].astype(str)
df["recommend_service_id"] = df["recommend_service_id"].astype(str)
df["is_related_service"] = df["is_related_service"].astype(int) df["is_related_service"] = df["is_related_service"].astype(int)
df["service_city"] = df["service_city"].fillna("") df["service_id"] = df["service_id"].astype(str)
df["recommend_service_id"] = df["recommend_service_id"].astype(str)
df["recommend_service_price"] = df["recommend_service_price"].astype(str)
df["service_id"] = df["service_city"].fillna("-1") df["service_id"] = df["service_city"].fillna("-1")
df["service_city"] = df["service_city"].fillna("")
df["recommend_service_id"] = df["recommend_service_id"].fillna("-1") df["recommend_service_id"] = df["recommend_service_id"].fillna("-1")
df["recommend_service_city"] = df["recommend_service_city"].fillna("") df["recommend_service_city"] = df["recommend_service_city"].fillna("")
......
...@@ -46,6 +46,12 @@ if __name__ == "__main__": ...@@ -46,6 +46,12 @@ if __name__ == "__main__":
tractate_dict = tractate_fe.get_tractate_dict_from_redis() tractate_dict = tractate_fe.get_tractate_dict_from_redis()
print("redis data: " + str(len(device_dict)) + " " + str(len(diary_dict)) + " " + str(len(tractate_dict))) print("redis data: " + str(len(device_dict)) + " " + str(len(diary_dict)) + " " + str(len(tractate_dict)))
# device_ids = list(device_dict.keys())[:20]
# tractate_ids = list(tractate_dict.keys())[:20]
# print(device_dict[device_ids[0]], "\n")
# print(tractate_dict[tractate_ids[0]], "\n")
diary_save_path = get_essm_model_save_path("diary") diary_save_path = get_essm_model_save_path("diary")
if not diary_save_path: if not diary_save_path:
diary_save_path = "/data/files/models/diary/1597390452" diary_save_path = "/data/files/models/diary/1597390452"
......
...@@ -65,7 +65,8 @@ def main(): ...@@ -65,7 +65,8 @@ def main():
estimator_config = tf.estimator.RunConfig(session_config=session_config) estimator_config = tf.estimator.RunConfig(session_config=session_config)
model = tf.estimator.Estimator(model_fn=esmm_model_fn, params=params, model_dir=model_path, config=estimator_config) model = tf.estimator.Estimator(model_fn=esmm_model_fn, params=params, model_dir=model_path, config=estimator_config)
train_spec = tf.estimator.TrainSpec(input_fn=lambda: esmm_input_fn(train_df, shuffle=True), max_steps=50000) # TODO 50000
train_spec = tf.estimator.TrainSpec(input_fn=lambda: esmm_input_fn(train_df, shuffle=True), max_steps=13000)
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False)) eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
res = tf.estimator.train_and_evaluate(model, train_spec, eval_spec) res = tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
...@@ -80,8 +81,9 @@ def main(): ...@@ -80,8 +81,9 @@ def main():
model_export_path = str(Path("/data/files/models/diary").expanduser()) model_export_path = str(Path("/data/files/models/diary").expanduser())
save_path = model_export(model, all_features, model_export_path) save_path = model_export(model, all_features, model_export_path)
print("save to: " + save_path) print("save to: " + save_path)
set_essm_model_save_path("diary", save_path) # TODO save model
record_esmm_auc_to_db("diary", ctr_auc, ctcvr_auc, total_time, save_path) # set_essm_model_save_path("diary", save_path)
# record_esmm_auc_to_db("diary", ctr_auc, ctcvr_auc, total_time, save_path)
print("============================================================") print("============================================================")
# save_path = str(Path("~/Desktop/models/1596012827").expanduser()) # local # save_path = str(Path("~/Desktop/models/1596012827").expanduser()) # local
......
...@@ -63,7 +63,7 @@ def main(): ...@@ -63,7 +63,7 @@ def main():
model = tf.estimator.Estimator(model_fn=esmm_model_fn, params=params, model_dir=model_path, config=estimator_config) model = tf.estimator.Estimator(model_fn=esmm_model_fn, params=params, model_dir=model_path, config=estimator_config)
# TODO 50000 # TODO 50000
train_spec = tf.estimator.TrainSpec(input_fn=lambda: esmm_input_fn(train_df, shuffle=True), max_steps=15000) train_spec = tf.estimator.TrainSpec(input_fn=lambda: esmm_input_fn(train_df, shuffle=True), max_steps=12000)
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False)) eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
res = tf.estimator.train_and_evaluate(model, train_spec, eval_spec) res = tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
...@@ -87,7 +87,7 @@ def main(): ...@@ -87,7 +87,7 @@ def main():
# print("load path: " + save_path) # print("load path: " + save_path)
# save_path = str(Path("~/data/models/tractate/1598236893").expanduser()) # local # save_path = str(Path("~/data/models/tractate/1598236893").expanduser()) # local
# save_path = "/data/files/models/tractate/1598254242" # server save_path = "/data/files/models/tractate/1599123885" # server
predict_fn = tf.contrib.predictor.from_saved_model(save_path) predict_fn = tf.contrib.predictor.from_saved_model(save_path)
device_dict = device_fe.get_device_dict_from_redis() device_dict = device_fe.get_device_dict_from_redis()
......
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