Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files
scoring_calculation_system.py
CHANGED
@@ -557,7 +557,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
557 |
|
558 |
def amplify_score(score):
|
559 |
"""
|
560 |
-
|
561 |
"""
|
562 |
# 基礎調整
|
563 |
adjusted = (score - 0.35) * 1.8
|
@@ -565,20 +565,16 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
565 |
# 使用 3.2 次方使曲線更平滑
|
566 |
amplified = pow(adjusted, 3.2) / 5.8 + score
|
567 |
|
568 |
-
# 加入細微的隨機變化(約±0.3%)
|
569 |
-
import random
|
570 |
-
random_adjustment = random.uniform(-0.003, 0.003)
|
571 |
-
|
572 |
# 特別處理高分區間,確保不超過95%
|
573 |
if amplified > 0.90:
|
574 |
# 壓縮高分區間,確保最高到95%
|
575 |
-
amplified = 0.90 + (
|
576 |
|
577 |
-
#
|
578 |
-
final_score = max(0.55, min(0.95, amplified
|
579 |
|
580 |
-
#
|
581 |
-
return
|
582 |
|
583 |
final_score = amplify_score(weighted_score)
|
584 |
|
|
|
557 |
|
558 |
def amplify_score(score):
|
559 |
"""
|
560 |
+
優化分數放大函數,確保分數範圍合理且結果一致
|
561 |
"""
|
562 |
# 基礎調整
|
563 |
adjusted = (score - 0.35) * 1.8
|
|
|
565 |
# 使用 3.2 次方使曲線更平滑
|
566 |
amplified = pow(adjusted, 3.2) / 5.8 + score
|
567 |
|
|
|
|
|
|
|
|
|
568 |
# 特別處理高分區間,確保不超過95%
|
569 |
if amplified > 0.90:
|
570 |
# 壓縮高分區間,確保最高到95%
|
571 |
+
amplified = 0.90 + (amplified - 0.90) * 0.5
|
572 |
|
573 |
+
# 確保最終分數在合理範圍內(0.55-0.95)
|
574 |
+
final_score = max(0.55, min(0.95, amplified))
|
575 |
|
576 |
+
# 四捨五入到小數點後第三位
|
577 |
+
return round(final_score, 3)
|
578 |
|
579 |
final_score = amplify_score(weighted_score)
|
580 |
|