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
0e5c0a3b
Commit
0e5c0a3b
authored
Oct 11, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logging
parent
a144d681
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
evaluation_metrics.py
eda/smart_rank/evaluation_metrics.py
+19
-14
No files found.
eda/smart_rank/evaluation_metrics.py
View file @
0e5c0a3b
...
...
@@ -8,6 +8,7 @@ import json
import
numpy
as
np
import
pandas
as
pd
from
tool
import
*
import
logging
def
get_user_service_portrait_not_alipay
(
cl_id
,
all_word_tags
,
all_tag_tag_type
,
all_3tag_2tag
,
size
=
10
):
...
...
@@ -116,6 +117,7 @@ if __name__ == '__main__':
# 获取昨天下单的用户设备id,下单的美购,美购对应的tag
# api_order只有用户的user_id,一个user_id对应多个device_id
# 用户一次可以下多个订单(美购),一个美购对应多个tag
LOG_DIR
=
"/home/gmuser/gyz/log/"
my_today
=
str
(
datetime
.
date
.
today
())
my_yesterday
=
str
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
1
))
sql_order_device_info_yesterday
=
"""
...
...
@@ -191,7 +193,7 @@ if __name__ == '__main__':
# 统计画像更新的耗时和更新的设备数
sql
=
"select count(*) from user_service_portrait_tags where stat_date='{my_today}'"
.
format
(
my_today
=
my_today
)
portrait_device_count
=
get_data_by_mysql
(
'172.16.40.158'
,
4000
,
'root'
,
'3SYz54LS9#^9sBvC'
,
'jerry_test'
,
sql
)
with
open
(
"/home/gmuser/gyz/log/
dist_portrait.log"
,
'r'
)
as
f
:
with
open
(
LOG_DIR
+
"
dist_portrait.log"
,
'r'
)
as
f
:
lines
=
f
.
readlines
()
start_datetime_str
=
lines
[
0
][:
19
]
end_datetime_str
=
lines
[
-
1
][:
19
]
...
...
@@ -199,18 +201,20 @@ if __name__ == '__main__':
end_datetime
=
datetime
.
datetime
.
strptime
(
end_datetime_str
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
time_consuming
=
(
end_datetime
-
start_datetime
)
.
seconds
/
60
print
(
"画像信息统计日期:"
,
my_today
)
print
(
"画像更新耗时:{time_consuming}分钟"
.
format
(
time_consuming
=
time_consuming
))
print
(
"画像更新的设备数:"
,
portrait_device_count
[
0
][
"count(*)"
])
print
(
""
)
print
(
"统计画像匹配度所用数据的日期:"
,
my_yesterday
)
print
(
"画像的前n个tag:"
,
cmd_portrait_top_n
)
print
(
"重合个数:"
,
cmd_coincide_n
)
print
(
"下单人数:"
,
result
[
"device_count"
])
print
(
"比对的上的人数:"
,
result
[
"coincide_count"
])
print
(
"匹配度:"
,
result
[
"coincide_rate"
])
print
(
"比对不上的有画像的人数:"
,
result
[
"not_coincide_have_portrait_count"
])
print
(
"比对不上的无画像的人数:"
,
result
[
"not_coincide_no_portrait_count"
])
print
(
"="
*
100
)
logging
.
basicConfig
(
format
=
'
%(message)
s'
,
filename
=
LOG_DIR
+
'portrait_stat.log'
,
filemode
=
'a'
,
level
=
logging
.
INFO
)
logging
.
info
({
"画像信息统计日期"
:
my_today
})
logging
.
info
({
"画像更新耗时(分钟)"
:
time_consuming
})
logging
.
info
({
"画像更新的设备数"
:
portrait_device_count
[
0
][
"count(*)"
]})
logging
.
info
(
""
)
logging
.
info
({
"统计画像匹配度所用数据的日期"
:
my_yesterday
})
logging
.
info
({
"统计画像的选取前n个tag"
:
cmd_portrait_top_n
})
logging
.
info
({
"重合个数"
:
cmd_coincide_n
})
logging
.
info
({
"下单人数"
:
result
[
"device_count"
]})
logging
.
info
({
"比对的上的人数"
:
result
[
"coincide_count"
]})
logging
.
info
({
"匹配度"
:
result
[
"coincide_rate"
]})
logging
.
info
({
"比对不上的有画像的人数"
:
result
[
"not_coincide_have_portrait_count"
]})
logging
.
info
({
"比对不上的无画像的人数"
:
result
[
"not_coincide_no_portrait_count"
]})
logging
.
info
(
"="
*
66
)
except
Exception
as
e
:
print
(
e
)
\ No newline at end of file
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