forked from zhanghe06/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_score.py
More file actions
83 lines (63 loc) · 1.18 KB
/
test_score.py
File metadata and controls
83 lines (63 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# encoding: utf-8
__author__ = 'zhanghe'
import math
def test_01(score, test_range):
"""
测试期望工资与薪资范围的匹配程度
:return:
"""
print score
print test_range
result = 1
if score not in test_range:
result = 1-min(abs(score-test_range[0]), abs(score-test_range[1]))/(score+sum(test_range)/2.0)
print '评分:%.2f\n' % result
def test_02(score, test_range):
"""
测试二(欧氏距离)
"""
avg_rang = sum(test_range)/2.0
print math.sqrt(abs(score**2-avg_rang**2))
if __name__ == '__main__':
test_01(20, [100, 200])
test_01(100, [100, 200])
test_01(90, [100, 200])
test_01(1000, [100, 200])
test_01(1000, [0, 0])
test_01(1000, [10, 10])
test_01(1000, [100, 100])
test_01(1000, [1000, 1000])
test_01(1000, [10000, 10000])
test_01(1000, [80000, 100000])
"""
20
[100, 200]
评分:0.53
100
[100, 200]
评分:1.00
90
[100, 200]
评分:0.96
1000
[100, 200]
评分:0.30
1000
[0, 0]
评分:0.00
1000
[10, 10]
评分:0.02
1000
[100, 100]
评分:0.18
1000
[1000, 1000]
评分:1.00
1000
[10000, 10000]
评分:0.18
1000
[80000, 100000]
评分:0.13
"""