Merge branch 'hp' into 'master'

update 修改打分逻辑

See merge request root/tfse_rating!28
This commit is contained in:
王思川 2022-01-25 08:51:50 +00:00
commit e776ba5576
1 changed files with 69 additions and 19 deletions

View File

@ -25,29 +25,49 @@ def financial_score(param1, param2):
# main
for key, value in param2.items():
# 已获利息倍数为None分数为满分
if key == '已获利息倍数' and value is None:
scores[key] = 5
elif value is None:
scores[key] = 0
else:
refer = list(map(float, refers[key]))
weight = weights[key]
if value is None:
score = 0
elif value > refer[0]:
# 判断打分是正相关还是反相关
if refer[0] > refer[1]:
# 正相关判断
if value >= refer[0]:
score = weight
elif value > refer[1]:
standard_score = round(weight * 1, 2)
score = linear_correlation_type(value, standard_score, refer[0], refer[1])
score = linear_correlation_type_positive(value, standard_score, refer[0])
elif value > refer[2]:
standard_score = round(weight * 0.8, 2)
score = linear_correlation_type(value, standard_score, refer[1], refer[2])
score = linear_correlation_type_positive(value, standard_score, refer[1])
elif value > refer[3]:
standard_score = round(weight * 0.5, 2)
score = linear_correlation_type(value, standard_score, refer[2], refer[3])
score = linear_correlation_type_positive(value, standard_score, refer[2])
elif value > refer[4]:
standard_score = round(weight * 0.25, 2)
score = linear_correlation_type(value, standard_score, refer[3], refer[4])
score = linear_correlation_type_positive(value, standard_score, refer[3])
else:
score = 0
else:
if value <= refer[0]:
score = weight
elif value < refer[1]:
standard_score = round(weight * 1, 2)
score = linear_correlation_type_anti(value, standard_score, refer[0])
elif value < refer[2]:
standard_score = round(weight * 0.8, 2)
score = linear_correlation_type_anti(value, standard_score, refer[1])
elif value < refer[3]:
standard_score = round(weight * 0.5, 2)
score = linear_correlation_type_anti(value, standard_score, refer[2])
elif value < refer[4]:
standard_score = round(weight * 0.25, 2)
score = linear_correlation_type_anti(value, standard_score, refer[3])
scores[key] = round(score, 2)
result = dict()
@ -92,7 +112,7 @@ def linear_correlation_type(value, standard_score, refer1, refer2):
elif value >= refer1:
score = standard_score
else:
score = standard_score - standard_score * (1 - (refer1 - value) / (refer1 - refer2))
score = standard_score * (1 - (refer1 - value) / (refer1 - refer2))
# 反相关打分
else:
if value <= refer2:
@ -100,6 +120,36 @@ def linear_correlation_type(value, standard_score, refer1, refer2):
elif value >= refer1:
score = 0
else:
score = standard_score - standard_score * (1 - (value - refer2) / (refer1 - refer2))
score = standard_score * (1 - (value - refer2) / (refer1 - refer2))
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