update 修改打分逻辑
This commit is contained in:
parent
d2282e4756
commit
df557c6f6c
|
@ -33,41 +33,34 @@ def financial_score(param1, param2):
|
||||||
else:
|
else:
|
||||||
refer = list(map(float, refers[key]))
|
refer = list(map(float, refers[key]))
|
||||||
weight = weights[key]
|
weight = weights[key]
|
||||||
# 判断打分是正相关还是反相关
|
standard = [weight, weight*0.8, weight*0.6, weight*0.4, weight*0.2]
|
||||||
|
# 判断正反相关
|
||||||
if refer[0] > refer[1]:
|
if refer[0] > refer[1]:
|
||||||
# 正相关判断
|
|
||||||
if value >= refer[0]:
|
if value >= refer[0]:
|
||||||
score = weight
|
score = weight
|
||||||
elif value > refer[1]:
|
elif value > refer[1]:
|
||||||
standard_score = round(weight * 1, 2)
|
score = linear_correlation_type(value, standard[0], standard[1], refer[0], refer[1])
|
||||||
score = linear_correlation_type_positive(value, standard_score, refer[0])
|
|
||||||
elif value > refer[2]:
|
elif value > refer[2]:
|
||||||
standard_score = round(weight * 0.8, 2)
|
score = linear_correlation_type(value, standard[1], standard[2], refer[1], refer[2])
|
||||||
score = linear_correlation_type_positive(value, standard_score, refer[1])
|
|
||||||
elif value > refer[3]:
|
elif value > refer[3]:
|
||||||
standard_score = round(weight * 0.5, 2)
|
score = linear_correlation_type(value, standard[2], standard[3], refer[2], refer[3])
|
||||||
score = linear_correlation_type_positive(value, standard_score, refer[2])
|
|
||||||
elif value > refer[4]:
|
elif value > refer[4]:
|
||||||
standard_score = round(weight * 0.25, 2)
|
score = linear_correlation_type(value, standard[3], standard[4], refer[3], refer[4])
|
||||||
score = linear_correlation_type_positive(value, standard_score, refer[3])
|
|
||||||
else:
|
else:
|
||||||
score = 0
|
score = 0
|
||||||
else:
|
else:
|
||||||
if value <= refer[0]:
|
if value <= refer[0]:
|
||||||
score = weight
|
score = weight
|
||||||
elif value < refer[1]:
|
elif value < refer[1]:
|
||||||
standard_score = round(weight * 1, 2)
|
score = linear_correlation_type(value, standard[0], standard[1], refer[0], refer[1])
|
||||||
score = linear_correlation_type_anti(value, standard_score, refer[0])
|
|
||||||
elif value < refer[2]:
|
elif value < refer[2]:
|
||||||
standard_score = round(weight * 0.8, 2)
|
score = linear_correlation_type(value, standard[1], standard[2], refer[1], refer[2])
|
||||||
score = linear_correlation_type_anti(value, standard_score, refer[1])
|
|
||||||
elif value < refer[3]:
|
elif value < refer[3]:
|
||||||
standard_score = round(weight * 0.5, 2)
|
score = linear_correlation_type(value, standard[2], standard[3], refer[2], refer[3])
|
||||||
score = linear_correlation_type_anti(value, standard_score, refer[2])
|
|
||||||
elif value < refer[4]:
|
elif value < refer[4]:
|
||||||
standard_score = round(weight * 0.25, 2)
|
score = linear_correlation_type(value, standard[3], standard[4], refer[3], refer[4])
|
||||||
score = linear_correlation_type_anti(value, standard_score, refer[3])
|
else:
|
||||||
|
score = 0
|
||||||
scores[key] = round(score, 2)
|
scores[key] = round(score, 2)
|
||||||
|
|
||||||
result = dict()
|
result = dict()
|
||||||
|
@ -93,63 +86,20 @@ def financial_score(param1, param2):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def linear_correlation_type(value, standard_score, refer1, refer2):
|
def linear_correlation_type(value, standard1, standard2, refer1, refer2):
|
||||||
"""
|
"""
|
||||||
线性相关类型 正相关/反相关
|
线性相关类型 正相关/反相关
|
||||||
Parameters
|
Parameters
|
||||||
value float 指标值
|
value float 指标值
|
||||||
standard_score float 标准分
|
standard1 float 标准分1
|
||||||
|
standard2 float 标准分2
|
||||||
refer1 阈值1
|
refer1 阈值1
|
||||||
refer2 阈值2
|
refer2 阈值2
|
||||||
Returns
|
Returns
|
||||||
score float 得分
|
score float 得分
|
||||||
"""
|
"""
|
||||||
# main
|
# main
|
||||||
# 正相关打分
|
score = standard2 + (value - refer2) / (refer1 - refer2) * (standard1 - standard2)
|
||||||
if refer1 > refer2:
|
|
||||||
if value <= refer2:
|
|
||||||
score = 0
|
|
||||||
elif value >= refer1:
|
|
||||||
score = standard_score
|
|
||||||
else:
|
|
||||||
score = standard_score * (1 - (refer1 - value) / (refer1 - refer2))
|
|
||||||
# 反相关打分
|
|
||||||
else:
|
|
||||||
if value <= refer2:
|
|
||||||
score = standard_score
|
|
||||||
elif value >= refer1:
|
|
||||||
score = 0
|
|
||||||
else:
|
|
||||||
score = standard_score * (1 - (value - refer2) / (refer1 - refer2))
|
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|
||||||
|
|
||||||
def linear_correlation_type_positive(value, standard_score, refer1):
|
|
||||||
"""
|
|
||||||
线性相关类型 正相关/反相关
|
|
||||||
Parameters
|
|
||||||
value float 指标值
|
|
||||||
standard_score float 标准分
|
|
||||||
refer1 阈值1
|
|
||||||
Returns
|
|
||||||
score float 得分
|
|
||||||
"""
|
|
||||||
score = standard_score * (value / refer1)
|
|
||||||
|
|
||||||
return score
|
|
||||||
|
|
||||||
|
|
||||||
def linear_correlation_type_anti(value, standard_score, refer1):
|
|
||||||
"""
|
|
||||||
线性相关类型 正相关/反相关
|
|
||||||
Parameters
|
|
||||||
value float 指标值
|
|
||||||
standard_score float 标准分
|
|
||||||
refer1 阈值1
|
|
||||||
Returns
|
|
||||||
score float 得分
|
|
||||||
"""
|
|
||||||
score = standard_score - (standard_score * (value / refer1) - standard_score)
|
|
||||||
|
|
||||||
return score
|
|
||||||
|
|
Loading…
Reference in New Issue