Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d9c1866f
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d9c1866f
编写于
2月 09, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add auc metric for client
上级
5672ecd4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
2 deletion
+69
-2
python/paddle_serving_client/metric/__init__.py
python/paddle_serving_client/metric/__init__.py
+13
-0
python/paddle_serving_client/metric/auc.py
python/paddle_serving_client/metric/auc.py
+51
-0
python/setup.py.client.in
python/setup.py.client.in
+5
-2
未找到文件。
python/paddle_serving_client/metric/__init__.py
0 → 100644
浏览文件 @
d9c1866f
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
python/paddle_serving_client/metric/auc.py
0 → 100644
浏览文件 @
d9c1866f
def
tied_rank
(
x
):
"""
Computes the tied rank of elements in x.
This function computes the tied rank of elements in x.
Parameters
----------
x : list of numbers, numpy array
Returns
-------
score : list of numbers
The tied rank f each element in x
"""
sorted_x
=
sorted
(
zip
(
x
,
range
(
len
(
x
))))
r
=
[
0
for
k
in
x
]
cur_val
=
sorted_x
[
0
][
0
]
last_rank
=
0
for
i
in
range
(
len
(
sorted_x
)):
if
cur_val
!=
sorted_x
[
i
][
0
]:
cur_val
=
sorted_x
[
i
][
0
]
for
j
in
range
(
last_rank
,
i
):
r
[
sorted_x
[
j
][
1
]]
=
float
(
last_rank
+
1
+
i
)
/
2.0
last_rank
=
i
if
i
==
len
(
sorted_x
)
-
1
:
for
j
in
range
(
last_rank
,
i
+
1
):
r
[
sorted_x
[
j
][
1
]]
=
float
(
last_rank
+
i
+
2
)
/
2.0
return
r
def
auc
(
actual
,
posterior
):
"""
Computes the area under the receiver-operater characteristic (AUC)
This function computes the AUC error metric for binary classification.
Parameters
----------
actual : list of binary numbers, numpy array
The ground truth value
posterior : same type as actual
Defines a ranking on the binary numbers, from most likely to
be positive to least likely to be positive.
Returns
-------
score : double
The mean squared error between actual and posterior
"""
r
=
tied_rank
(
posterior
)
num_positive
=
len
([
0
for
x
in
actual
if
x
==
1
])
num_negative
=
len
(
actual
)
-
num_positive
sum_positive
=
sum
([
r
[
i
]
for
i
in
range
(
len
(
r
))
if
actual
[
i
]
==
1
])
auc
=
((
sum_positive
-
num_positive
*
(
num_positive
+
1
)
/
2.0
)
/
(
num_negative
*
num_positive
))
return
auc
python/setup.py.client.in
浏览文件 @
d9c1866f
...
...
@@ -34,14 +34,17 @@ REQUIRED_PACKAGES = [
packages=['paddle_serving_client',
'paddle_serving_client.proto',
'paddle_serving_client.io']
'paddle_serving_client.io',
'paddle_serving_client.metric']
package_data={'paddle_serving_client': ['serving_client.so']}
package_dir={'paddle_serving_client':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client',
'paddle_serving_client.proto':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/proto',
'paddle_serving_client.io':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/io'}
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/io',
'paddle_serving_client.metric':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/metric'}
setup(
name='paddle-serving-client',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录