Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleRec
提交
87676102
P
PaddleRec
项目概览
PaddlePaddle
/
PaddleRec
通知
68
Star
12
Fork
5
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
27
列表
看板
标记
里程碑
合并请求
10
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
27
Issue
27
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
87676102
编写于
8月 21, 2020
作者:
Y
yinhaofeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add
上级
02fef740
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
0 deletion
+90
-0
tools/cal_pos_neg.py
tools/cal_pos_neg.py
+90
-0
未找到文件。
tools/cal_pos_neg.py
0 → 100644
浏览文件 @
87676102
#!/usr/bin/python
#-*- coding:utf-8 -*-
############################
#File Name: cal_pos_neg.py
#Author: youqiheng
#Mail: youqiheng@baidu.com
#Created Time: 2018-04-15 21:59:45
############################
"""
docstring
"""
import
os
import
sys
if
len
(
sys
.
argv
)
<
2
:
print
"usage:python %s input"
%
(
sys
.
argv
[
0
])
sys
.
exit
(
-
1
)
fin
=
file
(
sys
.
argv
[
1
])
pos_num
=
0
neg_num
=
0
score_list
=
[]
label_list
=
[]
last_query
=
"-1"
#0 12.786960 1
#0 -1.480890 0
cnt
=
0
query_num
=
0
pair_num
=
0
equal_num
=
0
for
line
in
fin
:
cols
=
line
.
strip
().
split
(
"
\t
"
)
cnt
+=
1
if
cnt
%
500000
==
0
:
print
"cnt:"
,
cnt
,
1.0
*
pos_num
/
neg_num
if
len
(
cols
)
!=
3
:
continue
cur_query
=
cols
[
0
]
if
cur_query
!=
last_query
:
query_num
+=
1
for
i
in
xrange
(
0
,
len
(
score_list
)):
for
j
in
xrange
(
i
+
1
,
len
(
score_list
)):
if
label_list
[
i
]
==
label_list
[
j
]:
continue
pair_num
+=
1
if
(
score_list
[
i
]
-
score_list
[
j
])
*
(
label_list
[
i
]
-
label_list
[
j
])
<
0
:
neg_num
+=
1
elif
(
score_list
[
i
]
-
score_list
[
j
])
*
(
label_list
[
i
]
-
label_list
[
j
])
>
0
:
pos_num
+=
1
else
:
equal_num
+=
1
score_list
=
[]
label_list
=
[]
last_query
=
cur_query
label
=
int
(
cols
[
2
])
score_list
.
append
(
round
(
float
(
cols
[
1
]),
6
))
label_list
.
append
(
int
(
cols
[
2
]))
fin
.
close
()
for
i
in
xrange
(
0
,
len
(
score_list
)):
for
j
in
xrange
(
i
+
1
,
len
(
score_list
)):
if
label_list
[
i
]
==
label_list
[
j
]:
continue
pair_num
+=
1
if
(
score_list
[
i
]
-
score_list
[
j
])
*
(
label_list
[
i
]
-
label_list
[
j
]
)
<
0
:
neg_num
+=
1
elif
(
score_list
[
i
]
-
score_list
[
j
])
*
(
label_list
[
i
]
-
label_list
[
j
]
)
>
0
:
pos_num
+=
1
else
:
equal_num
+=
1
if
neg_num
>
0
:
print
"pnr:"
,
1.0
*
pos_num
/
neg_num
print
"query_num:"
,
query_num
print
"pair_num:"
,
pos_num
+
neg_num
+
equal_num
,
pair_num
print
"equal_num:"
,
equal_num
print
"正序率:"
,
1.0
*
pos_num
/
(
pos_num
+
neg_num
)
print
pos_num
,
neg_num
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录