Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
30cd77b5
Commit
30cd77b5
authored
Aug 15, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5dc2f162
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
dist_update_user_portrait.py
eda/smart_rank/dist_update_user_portrait.py
+4
-4
No files found.
eda/smart_rank/dist_update_user_portrait.py
View file @
30cd77b5
...
...
@@ -41,7 +41,7 @@ def compute_validate(x):
return
score
else
:
return
0.5
def
tag_list2dict
(
lst
,
size
):
def
tag_list2dict
(
lst
):
result
=
[]
if
lst
:
for
i
in
lst
:
...
...
@@ -53,11 +53,11 @@ def tag_list2dict(lst,size):
tmp
[
"type"
]
=
"search_word"
tmp
[
"score"
]
=
i
[
"tag_score"
]
result
.
append
(
tmp
)
return
result
[:
size
]
return
result
def
get_user_tag_score
(
cl_id
,
all_log_df
):
user_log_df
=
all_log_df
.
loc
(
all_log_df
[
'cl_id'
]
==
cl_id
)
user_log_df
=
all_log_df
.
loc
[
all_log_df
[
'cl_id'
]
==
cl_id
]
if
not
user_log_df
.
empty
:
user_log_df
[
"tag_id"
]
=
np
.
where
(
user_log_df
[
"action"
]
==
"do_search"
,
user_log_df
[
"tag_referrer"
],
user_log_df
[
"tag_id"
])
user_log_df
[
"days_diff_now"
]
=
round
((
int
(
time
.
time
())
-
user_log_df
[
"time"
])
/
(
24
*
60
*
60
))
...
...
@@ -68,7 +68,7 @@ def get_user_tag_score(cl_id, all_log_df):
finally_score
=
user_log_df
.
sort_values
(
by
=
[
"tag_score"
,
"time"
],
ascending
=
False
)
finally_score
.
drop_duplicates
(
subset
=
"tag_id"
,
inplace
=
True
)
finally_score_lst
=
finally_score
[[
"tag_id"
,
"tag_score"
]]
.
to_dict
(
'record'
)
tag_id_list
=
tag_list2dict
(
finally_score_lst
,
size
)
tag_id_list
=
tag_list2dict
(
finally_score_lst
)
return
cl_id
,
tag_id_list
else
:
return
()
...
...
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