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
233a458a
Commit
233a458a
authored
Oct 11, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
argparse
parent
0e5c0a3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
evaluation_metrics.py
eda/smart_rank/evaluation_metrics.py
+12
-6
No files found.
eda/smart_rank/evaluation_metrics.py
View file @
233a458a
# -*- coding: UTF-8 -*-
# -*- coding: UTF-8 -*-
import
sys
import
argparse
import
pymysql
import
pymysql
import
redis
import
redis
import
datetime
import
datetime
...
@@ -114,12 +114,18 @@ def get_2_tags_coincide_rate(device_order_tags, device_portrait_result, portrait
...
@@ -114,12 +114,18 @@ def get_2_tags_coincide_rate(device_order_tags, device_portrait_result, portrait
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
try
:
# 获取昨天下单的用户设备id,下单的美购,美购对应的tag
parser
=
argparse
.
ArgumentParser
(
description
=
'画像匹配度的统计'
)
# api_order只有用户的user_id,一个user_id对应多个device_id
parser
.
add_argument
(
"-t"
,
"--top"
,
type
=
int
,
dest
=
"portrait_top_n"
,
default
=
3
,
help
=
"选取画像的前n个tag去统计匹配度"
)
# 用户一次可以下多个订单(美购),一个美购对应多个tag
parser
.
add_argument
(
"-c"
,
"--coincide"
,
type
=
int
,
dest
=
"coincide_n"
,
default
=
1
,
help
=
"选取n个tag重合个数作为判断是否匹配的阈值"
)
args
=
parser
.
parse_args
()
LOG_DIR
=
"/home/gmuser/gyz/log/"
LOG_DIR
=
"/home/gmuser/gyz/log/"
my_today
=
str
(
datetime
.
date
.
today
())
my_today
=
str
(
datetime
.
date
.
today
())
my_yesterday
=
str
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
1
))
my_yesterday
=
str
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
1
))
# 获取昨天下单的用户设备id,下单的美购,美购对应的tag
# api_order只有用户的user_id,一个user_id对应多个device_id
# 用户一次可以下多个订单(美购),一个美购对应多个tag
sql_order_device_info_yesterday
=
"""
sql_order_device_info_yesterday
=
"""
SELECT tmp1.user_id,
SELECT tmp1.user_id,
c.device_id,
c.device_id,
...
@@ -185,8 +191,8 @@ if __name__ == '__main__':
...
@@ -185,8 +191,8 @@ if __name__ == '__main__':
all_device_portrait_result
[
device
]
=
portrait_result
all_device_portrait_result
[
device
]
=
portrait_result
# 比较两个tag列表的重合率
# 比较两个tag列表的重合率
cmd_portrait_top_n
=
int
(
sys
.
argv
[
1
])
cmd_portrait_top_n
=
args
.
portrait_top_n
cmd_coincide_n
=
int
(
sys
.
argv
[
2
])
cmd_coincide_n
=
args
.
coincide_n
result
=
get_2_tags_coincide_rate
(
all_device_order_tags2
,
all_device_portrait_result
,
cmd_portrait_top_n
,
result
=
get_2_tags_coincide_rate
(
all_device_order_tags2
,
all_device_portrait_result
,
cmd_portrait_top_n
,
cmd_coincide_n
)
cmd_coincide_n
)
...
...
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