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
3cdb4896
Commit
3cdb4896
authored
Jul 22, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add printer
parent
456b31be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
main.py
src/main.py
+2
-2
fe.py
src/models/esmm/fe.py
+3
-1
model.py
src/models/esmm/model.py
+4
-2
No files found.
src/main.py
View file @
3cdb4896
...
...
@@ -14,7 +14,7 @@ from sklearn.model_selection import train_test_split
from
models.esmm.fe
import
(
click_feature_engineering
,
device_feature_engineering
,
diary_feature_engineering
,
get_device_dict_from_redis
,
get_diary_dict_from_redis
,
join_features
,
read_csv_data
)
from
models.esmm.input_fn
import
build_features
,
esmm_input_fn
from
models.esmm.model
import
esmm_model_fn
,
model_export
,
model_predict
2
from
models.esmm.model
import
esmm_model_fn
,
model_export
,
model_predict
_diary
# tf.compat.v1.enable_eager_execution()
...
...
@@ -94,7 +94,7 @@ def main():
for
i
in
range
(
2
):
time_1
=
timeit
.
default_timer
()
model_predict
2
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
200
),
device_dict
,
diary_dict
,
predict_fn
)
model_predict
_diary
(
random
.
sample
(
device_ids
,
1
)[
0
],
random
.
sample
(
diary_ids
,
200
),
device_dict
,
diary_dict
,
predict_fn
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"total prediction cost {:.5f}s"
.
format
(
total_1
),
"
\n
"
)
...
...
src/models/esmm/fe.py
View file @
3cdb4896
...
...
@@ -319,9 +319,11 @@ def device_diary_fe(device_id, diary_ids, device_dict, diary_dict):
device_info
[
"device_sp"
]
=
nth_element
(
device_sp
,
0
)
device_info
[
"device_p"
]
=
nth_element
(
device_p
,
0
)
diary_lst
=
[]
diary_ids_res
=
[]
for
id
in
diary_ids
:
diary_info
=
diary_dict
.
get
(
id
,
{})
.
copy
()
if
diary_info
:
diary_ids_res
.
append
(
diary_info
.
get
(
"card_id"
,
"-1"
))
diary_fd
=
diary_info
.
get
(
"first_demands"
,
[])
diary_sd
=
diary_info
.
get
(
"second_demands"
,
[])
diary_fs
=
diary_info
.
get
(
"first_solutions"
,
[])
...
...
@@ -367,4 +369,4 @@ def device_diary_fe(device_id, diary_ids, device_dict, diary_dict):
diary_lst
.
append
(
diary_info
)
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"join device diary cost {:.5f}s"
.
format
(
total_1
))
return
device_info
,
diary_lst
return
device_info
,
diary_lst
,
diary_ids_res
src/models/esmm/model.py
View file @
3cdb4896
...
...
@@ -95,9 +95,9 @@ def _bytes_feature(value):
return
tf
.
train
.
Feature
(
bytes_list
=
tf
.
train
.
BytesList
(
value
=
[
value
]))
def
model_predict
2
(
device_id
,
diary_ids
,
device_dict
,
diary_dict
,
predict_fn
):
def
model_predict
_diary
(
device_id
,
diary_ids
,
device_dict
,
diary_dict
,
predict_fn
):
time_1
=
timeit
.
default_timer
()
device_info
,
diary_lst
=
device_diary_fe
(
device_id
,
diary_ids
,
device_dict
,
diary_dict
)
device_info
,
diary_lst
,
diary_ids_res
=
device_diary_fe
(
device_id
,
diary_ids
,
device_dict
,
diary_dict
)
int_columns
=
[
"active_type"
,
"active_days"
,
"card_id"
,
"is_pure_author"
,
"is_have_reply"
,
"is_have_pure_reply"
,
"content_level"
,
"topic_num"
,
"favor_num"
,
"vote_num"
...
...
@@ -134,7 +134,9 @@ def model_predict2(device_id, diary_ids, device_dict, diary_dict, predict_fn):
diary_ids
.
append
(
i
.
get
(
"card_id"
,
"-1"
))
print
(
predictions
)
print
(
predictions
[
"output"
]
.
tolist
())
print
(
diary_ids_res
)
print
(
diary_ids
)
print
(
len
(
predictions
[
"output"
]
.
tolist
()),
len
(
diary_ids
),
len
(
diary_ids_res
))
total_1
=
(
timeit
.
default_timer
()
-
time_1
)
print
(
"prediction cost {:.5f}s"
.
format
(
total_1
))
return
predictions
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