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
51937cd8
Commit
51937cd8
authored
Nov 18, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update user
parent
c099f57b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
tag3_update_user_portrait_offline.py
eda/smart_rank/tag3_update_user_portrait_offline.py
+23
-2
tool.py
eda/smart_rank/tool.py
+3
-1
No files found.
eda/smart_rank/tag3_update_user_portrait_offline.py
View file @
51937cd8
...
...
@@ -187,6 +187,7 @@ def _get_all_by_projects(name_lst):
def
update_tag3_user_portrait
(
cl_id
):
user_df
=
get_tag3_user_log
(
cl_id
)
order_df
=
get_tag3_user_order_log
(
cl_id
)
if
not
user_df
.
empty
:
user_df
[
"first_solutions"
]
=
list
(
zip
(
user_df
[
"first_solutions"
]
.
apply
(
lambda
x
:
x
.
split
(
","
)),
user_df
[
"tag_score"
]))
user_df
[
"second_solutions"
]
=
list
(
zip
(
user_df
[
"second_solutions"
]
.
apply
(
lambda
x
:
x
.
split
(
","
)),
user_df
[
"tag_score"
]))
...
...
@@ -240,6 +241,24 @@ def update_tag3_user_portrait(cl_id):
if
k
not
in
forbidden_set
:
projects_score
[
k
]
=
v
paid_business_tags_score
=
{}
validate_business_tags_score
=
{}
if
not
order_df
.
empty
:
paid_order_df
=
order_df
[
order_df
[
"event_cn"
]
==
"支付订单"
]
if
not
paid_order_df
.
empty
:
paid_order_df
[
"business_tags"
]
=
list
(
zip
(
paid_order_df
[
"business_tags"
]
.
apply
(
lambda
x
:
x
.
split
(
","
)),
user_df
[
"tag_score"
]))
paid_order_df
[
"business_tags_dict"
]
=
paid_order_df
[
"business_tags"
]
.
apply
(
lambda
x
:
make_dict_from_pair
(
x
))
paid_business_tags_list
=
paid_order_df
[
"business_tags_dict"
]
.
tolist
()
paid_business_tags_score
=
merge_values
(
paid_business_tags_list
)
validate_order_df
=
order_df
[
order_df
[
"event_cn"
]
==
"验证订单"
]
if
not
validate_order_df
.
empty
:
validate_order_df
[
"business_tags"
]
=
list
(
zip
(
validate_order_df
[
"business_tags"
]
.
apply
(
lambda
x
:
x
.
split
(
","
)),
user_df
[
"tag_score"
]))
validate_order_df
[
"business_tags_dict"
]
=
validate_order_df
[
"business_tags"
]
.
apply
(
lambda
x
:
make_dict_from_pair
(
x
))
validate_business_tags_list
=
validate_order_df
[
"business_tags_dict"
]
.
tolist
()
validate_business_tags_score
=
merge_values
(
validate_business_tags_list
)
tmp_res
=
{}
if
(
len
(
first_demands_score
)
==
0
)
and
(
len
(
first_solutions_score
)
==
0
)
and
(
len
(
first_positions_score
)
==
0
)
and
(
len
(
second_demands_score
)
==
0
)
and
(
len
(
second_solutions_score
)
==
0
)
and
(
len
(
second_positions_score
)
==
0
):
...
...
@@ -253,7 +272,9 @@ def update_tag3_user_portrait(cl_id):
"first_positions"
:
first_positions_score
,
"second_positions"
:
second_positions_score
,
"projects"
:
projects_score
,
"business_tags"
:
business_tags_score
"business_tags"
:
business_tags_score
,
"paid_business_tags"
:
paid_business_tags_score
,
"validate_business_tags"
:
validate_business_tags_score
}
if
tmp_res
:
res
.
update
(
tmp_res
)
...
...
@@ -351,7 +372,7 @@ if __name__ == "__main__":
# update_tag3_user_portrait(cl_id)
cl_id
=
"867617044159377"
print
(
get_tag3_user_order_log
(
cl_id
))
print
(
update_tag3_user_portrait
(
cl_id
))
# consume_kafka() TODO
end
=
datetime
.
datetime
.
now
()
...
...
eda/smart_rank/tool.py
View file @
51937cd8
...
...
@@ -442,7 +442,8 @@ def get_tag3_user_log(cl_id):
return
pd
.
DataFrame
(
columns
=
columns
)
def
1
get_tag3_user_order_log
(
cl_id
):
# select log_time, score_type, business_tags, event_cn from kafka_tag3_log where cl_id = '867617044159377' and event_cn in ('支付订单', '验证订单');
def
get_tag3_user_order_log
(
cl_id
):
columns
=
[
"log_time"
,
"score_type"
,
"business_tags"
,
"event_cn"
]
...
...
@@ -465,6 +466,7 @@ def 1get_tag3_user_order_log(cl_id):
user_df
[
"days_diff_now"
]
=
round
((
int
(
time
.
time
())
-
user_df
[
"log_time"
]
.
astype
(
float
))
/
(
24
*
60
*
60
))
user_df
[
"tag_score"
]
=
user_df
.
apply
(
lambda
x
:
compute_tag3_score
(
x
),
axis
=
1
)
user_df
[
"business_tags"
]
=
user_df
[
"business_tags"
]
.
fillna
(
""
)
return
user_df
except
Exception
as
e
:
print
(
e
)
return
pd
.
DataFrame
(
columns
=
columns
)
...
...
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