Commit 83ff5d17 authored by 赵威's avatar 赵威

click_id for diary

parent 1a25cb59
......@@ -14,7 +14,8 @@ _categorical_columns = [
"device_id", "past_consume_ability_history", "potential_consume_ability_history", "price_sensitive_history", "device_fd",
"device_sd", "device_fs", "device_ss", "device_fp", "device_sp", "device_p", "content_fd", "content_sd", "content_fs",
"content_ss", "content_fp", "content_sp", "content_p", "fd1", "fd2", "fd3", "sd1", "sd2", "sd3", "fs1", "fs2", "fs3", "ss1",
"ss2", "ss3", "fp1", "fp2", "fp3", "sp1", "sp2", "sp3", "p1", "p2", "p3"
"ss2", "ss3", "fp1", "fp2", "fp3", "sp1", "sp2", "sp3", "p1", "p2", "p3", "click_diary_id1", "click_diary_id2",
"click_diary_id3", "click_diary_id4", "click_diary_id5"
]
PREDICTION_ALL_COLUMNS = _int_columns + _float_columns + _categorical_columns
......
......@@ -5,7 +5,7 @@ from utils.cache import redis_db_client
DIARY_DEVICE_COLUMNS = [
"device_id", "active_type", "active_days", "past_consume_ability_history", "potential_consume_ability_history",
"price_sensitive_history", "first_demands", "second_demands", "first_solutions", "second_solutions", "first_positions",
"second_positions", "projects"
"second_positions", "projects", "click_diary_id1", "click_diary_id2", "click_diary_id3", "click_diary_id4", "click_diary_id5"
]
TRACTATE_DEVICE_COLUMNS = [
......
......@@ -17,7 +17,8 @@ CATEGORICAL_COLUMNS = [
"card_id", "is_pure_author", "is_have_reply", "is_have_pure_reply", "content_level", "device_fd", "content_fd", "fd1", "fd2",
"fd3", "device_sd", "content_sd", "sd1", "sd2", "sd3", "device_fs", "content_fs", "fs1", "fs2", "fs3", "device_ss",
"content_ss", "ss1", "ss2", "ss3", "device_fp", "content_fp", "fp1", "fp2", "fp3", "device_sp", "content_sp", "sp1", "sp2",
"sp3", "device_p", "content_p", "p1", "p2", "p3"
"sp3", "device_p", "content_p", "p1", "p2", "p3", "click_diary_id1", "click_diary_id2", "click_diary_id3", "click_diary_id4",
"click_diary_id5"
]
......@@ -174,7 +175,12 @@ def device_diary_fe(device_id, diary_ids, device_dict, diary_dict):
"device_click_num_7d": 0,
"device_click_num_15d": 0,
"device_click_num_30d": 0,
"device_click_num_180d": 0
"device_click_num_180d": 0,
"click_diary_id1": "-1",
"click_diary_id2": "-1",
"click_diary_id3": "-1",
"click_diary_id4": "-1",
"click_diary_id5": "-1"
}
device_fd = device_info.get("first_demands", [])
device_sd = device_info.get("second_demands", [])
......
......@@ -24,7 +24,8 @@ def build_features(df, int_columns, float_columns, categorical_columns):
fc.embedding_column(fc.categorical_column_with_hash_bucket(col, 400000), dimension=int(df[col].size**0.25)))
elif col in [
"show_tag_id", "click_tractate_id1", "click_tractate_id2", "click_tractate_id3", "click_tractate_id4",
"click_tractate_id5"
"click_tractate_id5", "click_diary_id1", "click_diary_id2", "click_diary_id3", "click_diary_id4",
"click_diary_id5"
]:
categorical_features.append(
fc.embedding_column(fc.categorical_column_with_hash_bucket(col, 20000), dimension=int(df[col].size**0.25)))
......
......@@ -54,7 +54,8 @@ def main():
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)
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=10000)
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
......
......@@ -51,7 +51,8 @@ def main():
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)
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=10000)
eval_spec = tf.estimator.EvalSpec(input_fn=lambda: esmm_input_fn(val_df, shuffle=False))
tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
......
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