Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files
scoring_calculation_system.py
CHANGED
@@ -557,12 +557,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
557 |
|
558 |
def amplify_score(score):
|
559 |
"""
|
560 |
-
|
561 |
-
|
562 |
-
改進:
|
563 |
-
- 使用更自然的指數關係
|
564 |
-
- 加入細微的隨機變化
|
565 |
-
- 避免過多的整數和半數
|
566 |
"""
|
567 |
# 基礎調整
|
568 |
adjusted = (score - 0.35) * 1.8
|
@@ -574,14 +569,16 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
574 |
import random
|
575 |
random_adjustment = random.uniform(-0.003, 0.003)
|
576 |
|
577 |
-
#
|
578 |
-
if amplified > 0.
|
579 |
-
|
|
|
580 |
|
581 |
-
|
|
|
582 |
|
583 |
-
#
|
584 |
-
return round(final_score + random.uniform(-0.001, 0.001), 3)
|
585 |
|
586 |
final_score = amplify_score(weighted_score)
|
587 |
|
|
|
557 |
|
558 |
def amplify_score(score):
|
559 |
"""
|
560 |
+
優化分數放大函數,確保分數範圍合理
|
|
|
|
|
|
|
|
|
|
|
561 |
"""
|
562 |
# 基礎調整
|
563 |
adjusted = (score - 0.35) * 1.8
|
|
|
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 + (min(0.95, amplified) - 0.90) * 0.5
|
576 |
|
577 |
+
# 確保最終分數在合理範圍內
|
578 |
+
final_score = max(0.55, min(0.95, amplified + random_adjustment))
|
579 |
|
580 |
+
# 確保不超過95%
|
581 |
+
return min(0.95, round(final_score + random.uniform(-0.001, 0.001), 3))
|
582 |
|
583 |
final_score = amplify_score(weighted_score)
|
584 |
|