Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_strategy_cvr
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
gm_strategy_cvr
Commits
83ff5d17
Commit
83ff5d17
authored
Aug 10, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
click_id for diary
parent
1a25cb59
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
7 deletions
+17
-7
diary_model.py
src/models/esmm/diary_model.py
+2
-1
device_fe.py
src/models/esmm/fe/device_fe.py
+1
-1
diary_fe.py
src/models/esmm/fe/diary_fe.py
+8
-2
fe.py
src/models/esmm/fe/fe.py
+2
-1
train_diary.py
src/train_diary.py
+2
-1
train_tractate.py
src/train_tractate.py
+2
-1
No files found.
src/models/esmm/diary_model.py
View file @
83ff5d17
...
@@ -14,7 +14,8 @@ _categorical_columns = [
...
@@ -14,7 +14,8 @@ _categorical_columns = [
"device_id"
,
"past_consume_ability_history"
,
"potential_consume_ability_history"
,
"price_sensitive_history"
,
"device_fd"
,
"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"
,
"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"
,
"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
PREDICTION_ALL_COLUMNS
=
_int_columns
+
_float_columns
+
_categorical_columns
...
...
src/models/esmm/fe/device_fe.py
View file @
83ff5d17
...
@@ -5,7 +5,7 @@ from utils.cache import redis_db_client
...
@@ -5,7 +5,7 @@ from utils.cache import redis_db_client
DIARY_DEVICE_COLUMNS
=
[
DIARY_DEVICE_COLUMNS
=
[
"device_id"
,
"active_type"
,
"active_days"
,
"past_consume_ability_history"
,
"potential_consume_ability_history"
,
"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"
,
"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
=
[
TRACTATE_DEVICE_COLUMNS
=
[
...
...
src/models/esmm/fe/diary_fe.py
View file @
83ff5d17
...
@@ -17,7 +17,8 @@ CATEGORICAL_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"
,
"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"
,
"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"
,
"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):
...
@@ -174,7 +175,12 @@ def device_diary_fe(device_id, diary_ids, device_dict, diary_dict):
"device_click_num_7d"
:
0
,
"device_click_num_7d"
:
0
,
"device_click_num_15d"
:
0
,
"device_click_num_15d"
:
0
,
"device_click_num_30d"
:
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_fd
=
device_info
.
get
(
"first_demands"
,
[])
device_sd
=
device_info
.
get
(
"second_demands"
,
[])
device_sd
=
device_info
.
get
(
"second_demands"
,
[])
...
...
src/models/esmm/fe/fe.py
View file @
83ff5d17
...
@@ -24,7 +24,8 @@ def build_features(df, int_columns, float_columns, categorical_columns):
...
@@ -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
)))
fc
.
embedding_column
(
fc
.
categorical_column_with_hash_bucket
(
col
,
400000
),
dimension
=
int
(
df
[
col
]
.
size
**
0.25
)))
elif
col
in
[
elif
col
in
[
"show_tag_id"
,
"click_tractate_id1"
,
"click_tractate_id2"
,
"click_tractate_id3"
,
"click_tractate_id4"
,
"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
(
categorical_features
.
append
(
fc
.
embedding_column
(
fc
.
categorical_column_with_hash_bucket
(
col
,
20000
),
dimension
=
int
(
df
[
col
]
.
size
**
0.25
)))
fc
.
embedding_column
(
fc
.
categorical_column_with_hash_bucket
(
col
,
20000
),
dimension
=
int
(
df
[
col
]
.
size
**
0.25
)))
...
...
src/train_diary.py
View file @
83ff5d17
...
@@ -54,7 +54,8 @@ def main():
...
@@ -54,7 +54,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
=
10000
)
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
))
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
...
...
src/train_tractate.py
View file @
83ff5d17
...
@@ -51,7 +51,8 @@ def main():
...
@@ -51,7 +51,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
=
10000
)
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
))
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment