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
bd2c9b39
Commit
bd2c9b39
authored
Oct 10, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
a99f16c7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
+31
-5
evaluation_metrics.py
eda/smart_rank/evaluation_metrics.py
+31
-5
No files found.
eda/smart_rank/evaluation_metrics.py
View file @
bd2c9b39
...
@@ -84,16 +84,31 @@ def get_user_service_portrait_not_alipay(cl_id, all_word_tags, all_tag_tag_type,
...
@@ -84,16 +84,31 @@ def get_user_service_portrait_not_alipay(cl_id, all_word_tags, all_tag_tag_type,
def
get_2_tags_coincide_rate
(
device_order_tags
,
device_portrait_result
,
portrait_top_n
,
coincide_n
):
def
get_2_tags_coincide_rate
(
device_order_tags
,
device_portrait_result
,
portrait_top_n
,
coincide_n
):
device_count
=
len
(
device_order_tags
)
device_count
=
len
(
device_order_tags
)
coincide_count
=
0
coincide_count
=
0
not_coincide_no_portrait
=
0
not_coincide_no_portrait_device_ids
=
[]
not_coincide_have_portrait_device_ids
=
[]
not_coincide_have_portrait
=
0
for
device
in
device_order_tags
:
for
device
in
device_order_tags
:
order_tags
=
device_order_tags
[
device
]
order_tags
=
device_order_tags
[
device
]
portrait_tags
=
device_portrait_result
[
device
]
portrait_tags
=
device_portrait_result
[
device
]
if
portrait_tags
:
if
portrait_tags
:
portrait_tags
=
portrait_tags
[:
portrait_top_n
]
portrait_tags
=
portrait_tags
[:
portrait_top_n
]
else
:
else
:
portrait_tags
=
[]
not_coincide_no_portrait
+=
1
not_coincide_no_portrait_device_ids
.
append
(
device
)
continue
if
len
(
set
(
order_tags
)
.
intersection
(
set
(
portrait_tags
)))
>=
coincide_n
:
if
len
(
set
(
order_tags
)
.
intersection
(
set
(
portrait_tags
)))
>=
coincide_n
:
coincide_count
+=
1
coincide_count
+=
1
return
coincide_count
/
device_count
else
:
not_coincide_have_portrait
+=
1
not_coincide_have_portrait_device_ids
.
append
(
device
)
coincide_rate
=
coincide_count
/
device_count
result
=
{
"device_count"
:
device_count
,
"coincide_count"
:
coincide_count
,
"coincide_rate"
:
coincide_rate
,
"not_coincide_have_portrait_count"
:
not_coincide_have_portrait
,
"not_coincide_no_portrait_count"
:
not_coincide_no_portrait
,
"not_coincide_no_portrait_device_ids"
:
not_coincide_no_portrait_device_ids
,
"not_coincide_have_portrait_device_ids"
:
not_coincide_have_portrait_device_ids
}
return
result
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -154,11 +169,21 @@ if __name__ == '__main__':
...
@@ -154,11 +169,21 @@ if __name__ == '__main__':
# 昨天下单了的用户的去除支付行为的画像
# 昨天下单了的用户的去除支付行为的画像
all_device_portrait_result
=
dict
()
all_device_portrait_result
=
dict
()
for
device
in
device_ids_lst
:
for
device
in
device_ids_lst
:
portrait_result
=
get_user_service_portrait_not_alipay
(
device
,
all_word_tags
,
all_tag_tag_type
,
all_3tag_2tag
,
size
=
10
)
portrait_result
=
get_user_service_portrait_not_alipay
(
device
,
all_word_tags
,
all_tag_tag_type
,
all_3tag_2tag
,
size
=
10
)
all_device_portrait_result
[
device
]
=
portrait_result
all_device_portrait_result
[
device
]
=
portrait_result
# 比较两个tag列表的重合率
# 比较两个tag列表的重合率
rate
=
get_2_tags_coincide_rate
(
all_device_order_tags
,
all_device_portrait_result
,
3
,
1
)
cmd_portrait_top_n
=
sys
.
argv
[
1
]
print
(
rate
)
cmd_coincide_n
=
sys
.
argv
[
2
]
result
=
get_2_tags_coincide_rate
(
all_device_order_tags
,
all_device_portrait_result
,
cmd_portrait_top_n
,
cmd_coincide_n
)
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"
])
except
Exception
as
e
:
except
Exception
as
e
:
print
(
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