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
cbd232af
Commit
cbd232af
authored
Aug 03, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try predict
parent
bd222b61
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
6 deletions
+43
-6
main_portrait.py
src/main_portrait.py
+3
-3
portrait.py
src/utils/portrait.py
+40
-3
No files found.
src/main_portrait.py
View file @
cbd232af
...
@@ -77,7 +77,7 @@ def main():
...
@@ -77,7 +77,7 @@ def 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
)))
diary_save_path
=
"/home/gmuser/data/models/diary/1596
180627
"
diary_save_path
=
"/home/gmuser/data/models/diary/1596
423214
"
diary_predict_fn
=
tf
.
contrib
.
predictor
.
from_saved_model
(
diary_save_path
)
diary_predict_fn
=
tf
.
contrib
.
predictor
.
from_saved_model
(
diary_save_path
)
tractate_save_path
=
"/home/gmuser/data/models/tractate/1596181210"
tractate_save_path
=
"/home/gmuser/data/models/tractate/1596181210"
...
@@ -91,8 +91,8 @@ def main():
...
@@ -91,8 +91,8 @@ def main():
# print(len(res))
# print(len(res))
# print(res[:10])
# print(res[:10])
tail_number
=
sys
.
argv
[
1
]
# "c", "d", "e", "f"
#
tail_number = sys.argv[1] # "c", "d", "e", "f"
user_portrait_scan_info
(
device_dict
,
diary_dict
,
tractate_dict
,
diary_predict_fn
,
tractate_predict_fn
,
tail_number
)
#
user_portrait_scan_info(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn, tail_number)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
src/utils/portrait.py
View file @
cbd232af
...
@@ -102,6 +102,16 @@ def _user_portrait_tag3_get_candidate_key(device_id, content_type, latest=False)
...
@@ -102,6 +102,16 @@ def _user_portrait_tag3_get_candidate_key(device_id, content_type, latest=False)
return
key
return
key
def
_user_portrait_tag3_get_samecity_candidate_key
(
device_id
,
content_type
):
key
=
"doris:user_partrait:tag3:samecity:candidate:{}:device_id:{}"
.
format
(
content_type
,
device_id
)
return
key
def
_user_portrait_tag3_get_nearbycity_candidate_key
(
device_id
,
content_type
):
key
=
"doris:user_partrait:tag3:nearbycity:candidate:{}:device_id:{}"
.
format
(
content_type
,
device_id
)
return
key
def
_get_user_portrait_tag3_read_key_v2
(
device_id
,
content_type
):
def
_get_user_portrait_tag3_read_key_v2
(
device_id
,
content_type
):
return
"doris:user_portrait:tag3:read_v2:device_id:{}:content_type:{}"
.
format
(
device_id
,
content_type
)
return
"doris:user_portrait:tag3:read_v2:device_id:{}:content_type:{}"
.
format
(
device_id
,
content_type
)
...
@@ -132,6 +142,22 @@ def user_portrait_tag3_get_candidate_dict(device_id, content_type, latest=False)
...
@@ -132,6 +142,22 @@ def user_portrait_tag3_get_candidate_dict(device_id, content_type, latest=False)
return
{}
return
{}
def
user_portrait_tag3_get_samecity_candidate_dict
(
device_id
,
content_type
,
latest
=
False
):
key
=
_user_portrait_tag3_get_samecity_candidate_key
(
device_id
,
content_type
)
res
=
redis_client4
.
get
(
key
)
if
res
:
return
json
.
loads
(
res
)
return
{}
def
user_portrait_tag3_get_nearbycity_candidate_dict
(
device_id
,
content_type
,
latest
=
False
):
key
=
_user_portrait_tag3_get_nearbycity_candidate_key
(
device_id
,
content_type
)
res
=
redis_client4
.
get
(
key
)
if
res
:
return
json
.
loads
(
res
)
return
{}
def
user_portrait_tag3_get_candidate_unread_list
(
device_id
,
content_type
,
size
=
500
):
def
user_portrait_tag3_get_candidate_unread_list
(
device_id
,
content_type
,
size
=
500
):
"""
"""
device_id:
device_id:
...
@@ -139,12 +165,23 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type, size=5
...
@@ -139,12 +165,23 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type, size=5
return: []
return: []
"""
"""
queue
=
[]
queue
=
[]
lists
=
[]
read_list
,
_
=
get_user_portrait_tag3_read_v2
(
device_id
,
content_type
)
read_list
,
_
=
get_user_portrait_tag3_read_v2
(
device_id
,
content_type
)
data_dict
=
user_portrait_tag3_get_candidate_dict
(
device_id
,
content_type
)
if
content_type
==
"diary"
:
if
data_dict
:
data_dict
=
user_portrait_tag3_get_samecity_candidate_dict
(
device_id
,
content_type
)
lol
=
data_dict
.
values
()
lol
=
data_dict
.
values
()
lists
=
merge_lists
(
*
lol
)
lists
=
merge_lists
(
*
lol
)
queue
=
get_n_unread_data_from_ids
(
lists
,
size
,
read_list
)
if
len
(
lists
)
<
10
:
data_dict
=
user_portrait_tag3_get_nearbycity_candidate_dict
(
device_id
,
content_type
)
lol
=
data_dict
.
values
()
lists2
=
merge_lists
(
*
lol
)
lists
.
extend
(
lists2
)
else
:
data_dict
=
user_portrait_tag3_get_candidate_dict
(
device_id
,
content_type
)
lol
=
data_dict
.
values
()
lists
=
merge_lists
(
*
lol
)
queue
=
get_n_unread_data_from_ids
(
lists
,
size
,
read_list
)
return
queue
return
queue
...
...
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