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
6514a1e5
Commit
6514a1e5
authored
Dec 27, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
画像更新逻辑线均分,后衰减
parent
79a464dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
dist_update_user_portrait_service.py
eda/smart_rank/dist_update_user_portrait_service.py
+5
-5
tool.py
eda/smart_rank/tool.py
+15
-15
No files found.
eda/smart_rank/dist_update_user_portrait_service.py
View file @
6514a1e5
...
...
@@ -41,11 +41,11 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
user_df_service
[
"tag2_type"
]
=
user_df_service
.
apply
(
lambda
x
:
all_tag_tag_type
.
get
(
x
[
"tag2"
]),
axis
=
1
)
# 算分及比例
user_df_service
[
"tag_score"
]
=
user_df_service
.
apply
(
lambda
x
:
compute_henqiang
(
x
.
days_diff_now
,
exponential
=
1
)
/
get_action_tag_count
(
user_df_service
,
x
.
time
)
if
x
.
score_type
==
"henqiang"
else
(
compute_jiaoqiang
(
x
.
days_diff_now
,
exponential
=
1
)
/
get_action_tag_count
(
user_df_service
,
x
.
time
)
if
x
.
score_type
==
"jiaoqiang"
else
(
compute_ai_scan
(
x
.
days_diff_now
,
exponential
=
1
)
/
get_action_tag_count
(
user_df_service
,
x
.
time
)
if
x
.
score_type
==
"ai_scan"
else
(
compute_ruoyixiang
(
x
.
days_diff_now
,
exponential
=
1
)
/
get_action_tag_count
(
user_df_service
,
x
.
time
)
if
x
.
score_type
==
"ruoyixiang"
else
compute_validate
(
x
.
days_diff_now
,
exponential
=
1
)
/
get_action_tag_count
(
user_df_service
,
x
.
time
)))),
axis
=
1
)
lambda
x
:
compute_henqiang
(
x
.
days_diff_now
,
exponential
=
1
,
action_tag_count
=
get_action_tag_count
(
user_df_service
,
x
.
time
)
)
if
x
.
score_type
==
"henqiang"
else
(
compute_jiaoqiang
(
x
.
days_diff_now
,
exponential
=
1
,
action_tag_count
=
get_action_tag_count
(
user_df_service
,
x
.
time
)
)
if
x
.
score_type
==
"jiaoqiang"
else
(
compute_ai_scan
(
x
.
days_diff_now
,
exponential
=
1
,
action_tag_count
=
get_action_tag_count
(
user_df_service
,
x
.
time
)
)
if
x
.
score_type
==
"ai_scan"
else
(
compute_ruoyixiang
(
x
.
days_diff_now
,
exponential
=
1
,
action_tag_count
=
get_action_tag_count
(
user_df_service
,
x
.
time
)
)
if
x
.
score_type
==
"ruoyixiang"
else
compute_validate
(
x
.
days_diff_now
,
exponential
=
1
,
action_tag_count
=
get_action_tag_count
(
user_df_service
,
x
.
time
)
)))),
axis
=
1
)
tag_score_sum
=
user_df_service
.
groupby
(
by
=
[
"tag2"
,
"tag2_type"
])
.
agg
(
{
'tag_score'
:
'sum'
,
'cl_id'
:
'first'
,
'action'
:
'first'
})
.
reset_index
()
.
sort_values
(
by
=
[
"tag_score"
],
ascending
=
False
)
...
...
eda/smart_rank/tool.py
View file @
6514a1e5
...
...
@@ -236,52 +236,52 @@ def get_tag2_from_tag3(tag3, all_3tag_2tag, user_log_df_tag2_list):
print
(
e
)
def
compute_henqiang
(
x
,
decay_days
=
30
,
exponential
=
0
):
def
compute_henqiang
(
x
,
decay_days
=
30
,
exponential
=
0
,
action_tag_count
=
1
):
if
exponential
:
alpha
=
exponential_decay
(
x
,
decay_days
)
score
=
15
-
1.1
**
alpha
*
((
15
-
0.5
)
/
decay_days
)
score
=
15
/
action_tag_count
-
1.1
**
alpha
*
((
15
-
0.5
)
/
decay_days
)
else
:
score
=
15
-
x
*
((
15
-
0.5
)
/
decay_days
)
score
=
15
/
action_tag_count
-
x
*
((
15
-
0.5
)
/
decay_days
)
if
score
>
0.5
:
return
score
else
:
return
0.5
def
compute_jiaoqiang
(
x
,
decay_days
=
30
,
exponential
=
0
):
def
compute_jiaoqiang
(
x
,
decay_days
=
30
,
exponential
=
0
,
action_tag_count
=
1
):
if
exponential
:
alpha
=
exponential_decay
(
x
,
decay_days
)
score
=
12
-
1.1
**
alpha
*
((
12
-
0.5
)
/
decay_days
)
score
=
12
/
action_tag_count
-
1.1
**
alpha
*
((
12
-
0.5
)
/
decay_days
)
else
:
score
=
12
-
x
*
((
12
-
0.5
)
/
decay_days
)
score
=
12
/
action_tag_count
-
x
*
((
12
-
0.5
)
/
decay_days
)
if
score
>
0.5
:
return
score
else
:
return
0.5
def
compute_ruoyixiang
(
x
,
decay_days
=
30
,
exponential
=
0
):
def
compute_ruoyixiang
(
x
,
decay_days
=
30
,
exponential
=
0
,
action_tag_count
=
1
):
if
exponential
:
alpha
=
exponential_decay
(
x
,
decay_days
)
score
=
5
-
1.1
**
alpha
*
((
5
-
0.5
)
/
decay_days
)
score
=
5
/
action_tag_count
-
1.1
**
alpha
*
((
5
-
0.5
)
/
decay_days
)
else
:
score
=
5
-
x
*
((
5
-
0.5
)
/
decay_days
)
score
=
5
/
action_tag_count
-
x
*
((
5
-
0.5
)
/
decay_days
)
if
score
>
0.5
:
return
score
else
:
return
0.5
def
compute_validate
(
x
,
decay_days
=
30
,
exponential
=
0
):
def
compute_validate
(
x
,
decay_days
=
30
,
exponential
=
0
,
action_tag_count
=
1
):
if
exponential
:
alpha
=
exponential_decay
(
x
,
decay_days
)
score
=
10
-
1.1
**
alpha
*
((
10
-
0.5
)
/
decay_days
)
score
=
10
/
action_tag_count
-
1.1
**
alpha
*
((
10
-
0.5
)
/
decay_days
)
else
:
score
=
10
-
x
*
((
10
-
0.5
)
/
decay_days
)
score
=
10
/
action_tag_count
-
x
*
((
10
-
0.5
)
/
decay_days
)
if
score
>
0.5
:
return
score
else
:
return
0.5
def
compute_ai_scan
(
x
,
decay_days
=
30
,
exponential
=
0
):
def
compute_ai_scan
(
x
,
decay_days
=
30
,
exponential
=
0
,
action_tag_count
=
1
):
if
exponential
:
alpha
=
exponential_decay
(
x
,
decay_days
)
score
=
2
-
1.1
**
alpha
*
((
2
-
0.5
)
/
decay_days
)
score
=
2
/
action_tag_count
-
1.1
**
alpha
*
((
2
-
0.5
)
/
decay_days
)
else
:
score
=
2
-
x
*
((
2
-
0.5
)
/
decay_days
)
score
=
2
/
action_tag_count
-
x
*
((
2
-
0.5
)
/
decay_days
)
if
score
>
0.5
:
return
score
else
:
...
...
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