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
f62a3b38
Commit
f62a3b38
authored
Aug 14, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature for diary
parent
7eec6082
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
255 additions
and
38 deletions
+255
-38
diary_model.py
src/models/esmm/diary_model.py
+82
-11
diary_fe.py
src/models/esmm/fe/diary_fe.py
+171
-23
train_diary.py
src/train_diary.py
+2
-4
No files found.
src/models/esmm/diary_model.py
View file @
f62a3b38
...
...
@@ -6,17 +6,88 @@ from .fe.diary_fe import device_diary_fe
from
.model
import
_bytes_feature
,
_float_feature
,
_int64_feature
_int_columns
=
[
"active_type"
,
"active_days"
,
"card_id"
,
"is_pure_author"
,
"is_have_reply"
,
"is_have_pure_reply"
,
"content_level"
,
"topic_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"seven_transform_num"
,
"thirty_transform_num"
"active_type"
,
"active_days"
,
"card_id"
,
"is_pure_author"
,
"is_have_reply"
,
"is_have_pure_reply"
,
"content_level"
,
"topic_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"vote_display_num"
,
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"seven_transform_num"
,
"thirty_transform_num"
,
"one_browse_user_num"
,
"three_browse_user_num"
,
"seven_browse_user_num"
,
"fifteen_browse_user_num"
,
"thirty_browse_user_num"
,
"sixty_browse_user_num"
,
"ninety_browse_user_num"
,
"history_browse_user_num"
,
"one_vote_pure_rate"
,
"three_vote_pure_rate"
,
"seven_vote_pure_rate"
,
"fifteen_vote_pure_rate"
,
"thirty_vote_pure_rate"
,
"sixty_vote_pure_rate"
,
"ninety_vote_pure_rate"
,
"history_vote_pure_rate"
,
"one_reply_pure_rate"
,
"three_reply_pure_rate"
,
"seven_reply_pure_rate"
,
"fifteen_reply_pure_rate"
,
"thirty_reply_pure_rate"
,
"sixty_reply_pure_rate"
,
"ninety_reply_pure_rate"
,
"history_reply_pure_rate"
,
]
_float_columns
=
[
"one_ctr"
,
"three_ctr"
,
"seven_ctr"
,
"fifteen_ctr"
,
"thirty_ctr"
,
"sixty_ctr"
,
"ninety_ctr"
,
"history_ctr"
]
_categorical_columns
=
[
...
...
src/models/esmm/fe/diary_fe.py
View file @
f62a3b38
...
...
@@ -6,31 +6,179 @@ from utils.cache import redis_db_client
from
..utils
import
common_elements
,
nth_element
DIARY_COLUMNS
=
[
"card_id"
,
"is_pure_author"
,
"is_have_reply"
,
"is_have_pure_reply"
,
"content_level"
,
"topic_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"seven_transform_num"
,
"thirty_transform_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"one_ctr"
,
"three_ctr"
,
"seven_ctr"
,
"fifteen_ctr"
,
"thirty_ctr"
,
"sixty_ctr"
,
"ninety_ctr"
,
"history_ctr"
,
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
"first_positions"
,
"second_positions"
,
"projects"
"card_id"
,
"is_pure_author"
,
"is_have_reply"
,
"is_have_pure_reply"
,
"content_level"
,
"topic_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"seven_transform_num"
,
"thirty_transform_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"vote_display_num"
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"one_browse_user_num"
,
"three_browse_user_num"
,
"seven_browse_user_num"
,
"fifteen_browse_user_num"
,
"thirty_browse_user_num"
,
"sixty_browse_user_num"
,
"ninety_browse_user_num"
,
"history_browse_user_num"
,
"one_vote_pure_rate"
,
"three_vote_pure_rate"
,
"seven_vote_pure_rate"
,
"fifteen_vote_pure_rate"
,
"thirty_vote_pure_rate"
,
"sixty_vote_pure_rate"
,
"ninety_vote_pure_rate"
,
"history_vote_pure_rate"
,
"one_reply_pure_rate"
,
"three_reply_pure_rate"
,
"seven_reply_pure_rate"
,
"fifteen_reply_pure_rate"
,
"thirty_reply_pure_rate"
,
"sixty_reply_pure_rate"
,
"ninety_reply_pure_rate"
,
"history_reply_pure_rate"
,
"one_ctr"
,
"three_ctr"
,
"seven_ctr"
,
"fifteen_ctr"
,
"thirty_ctr"
,
"sixty_ctr"
,
"ninety_ctr"
,
"history_ctr"
,
"first_demands"
,
"second_demands"
,
"first_solutions"
,
"second_solutions"
,
"first_positions"
,
"second_positions"
,
"projects"
,
]
INT_COLUMNS
=
[
"active_days"
,
"topic_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"seven_transform_num"
,
"thirty_transform_num"
"active_days"
,
"topic_num"
,
"favor_num"
,
"favor_pure_num"
,
"vote_num"
,
"vote_display_num"
,
"reply_num"
,
"reply_pure_num"
,
"one_reply_user_num"
,
"three_reply_user_num"
,
"seven_reply_user_num"
,
"fifteen_reply_user_num"
,
"thirty_reply_user_num"
,
"sixty_reply_user_num"
,
"ninety_reply_user_num"
,
"history_reply_user_num"
,
"one_reply_num"
,
"three_reply_num"
,
"seven_reply_num"
,
"fifteen_reply_num"
,
"thirty_reply_num"
,
"sixty_reply_num"
,
"ninety_reply_num"
,
"history_reply_num"
,
"one_click_num"
,
"three_click_num"
,
"seven_click_num"
,
"fifteen_click_num"
,
"thirty_click_num"
,
"sixty_click_num"
,
"ninety_click_num"
,
"history_click_num"
,
"topic_seven_click_num"
,
"topic_thirty_click_num"
,
"one_precise_exposure_num"
,
"three_precise_exposure_num"
,
"seven_precise_exposure_num"
,
"fifteen_precise_exposure_num"
,
"thirty_precise_exposure_num"
,
"sixty_precise_exposure_num"
,
"ninety_precise_exposure_num"
,
"history_precise_exposure_num"
,
"one_vote_user_num"
,
"three_vote_user_num"
,
"seven_vote_user_num"
,
"fifteen_vote_user_num"
,
"thirty_vote_user_num"
,
"sixty_vote_user_num"
,
"ninety_vote_user_num"
,
"history_vote_user_num"
,
"seven_transform_num"
,
"thirty_transform_num"
,
"one_browse_user_num"
,
"three_browse_user_num"
,
"seven_browse_user_num"
,
"fifteen_browse_user_num"
,
"thirty_browse_user_num"
,
"sixty_browse_user_num"
,
"ninety_browse_user_num"
,
"history_browse_user_num"
,
"one_vote_pure_rate"
,
"three_vote_pure_rate"
,
"seven_vote_pure_rate"
,
"fifteen_vote_pure_rate"
,
"thirty_vote_pure_rate"
,
"sixty_vote_pure_rate"
,
"ninety_vote_pure_rate"
,
"history_vote_pure_rate"
,
"one_reply_pure_rate"
,
"three_reply_pure_rate"
,
"seven_reply_pure_rate"
,
"fifteen_reply_pure_rate"
,
"thirty_reply_pure_rate"
,
"sixty_reply_pure_rate"
,
"ninety_reply_pure_rate"
,
"history_reply_pure_rate"
,
]
FLOAT_COLUMNS
=
[
"one_ctr"
,
"three_ctr"
,
"seven_ctr"
,
"fifteen_ctr"
,
"thirty_ctr"
,
"sixty_ctr"
,
"ninety_ctr"
,
"history_ctr"
]
CATEGORICAL_COLUMNS
=
[
...
...
src/train_diary.py
View file @
f62a3b38
...
...
@@ -61,8 +61,7 @@ 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
)
# TODO 50000
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
20000
)
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
50000
)
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
)
print
(
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
)
...
...
@@ -74,8 +73,7 @@ def main():
model_export_path
=
str
(
Path
(
"~/data/models/diary"
)
.
expanduser
())
save_path
=
model_export
(
model
,
all_features
,
model_export_path
)
print
(
"save to: "
+
save_path
)
# TODO save model
# set_essm_model_save_path("diary", save_path)
set_essm_model_save_path
(
"diary"
,
save_path
)
print
(
"============================================================"
)
# save_path = str(Path("~/Desktop/models/1596012827").expanduser()) # local
# save_path = "/home/gmuser/data/models/diary/1596083349" # server
...
...
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