Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +36 -29
scoring_calculation_system.py
CHANGED
|
@@ -2102,47 +2102,54 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
| 2102 |
|
| 2103 |
|
| 2104 |
def amplify_score_extreme(score: float) -> float:
|
| 2105 |
-
"""
|
| 2106 |
-
|
| 2107 |
-
|
| 2108 |
-
|
|
|
|
| 2109 |
"""
|
| 2110 |
def smooth_curve(x: float, steepness: float = 12) -> float:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2111 |
import math
|
| 2112 |
return 1 / (1 + math.exp(-steepness * (x - 0.5)))
|
| 2113 |
|
| 2114 |
-
|
| 2115 |
-
"""增加分數的區分度"""
|
| 2116 |
-
# 根據原始分數的位置增加區分
|
| 2117 |
-
position_factor = base_score - int(base_score * 10) / 10
|
| 2118 |
-
return base_score + (position_factor * distinction)
|
| 2119 |
-
|
| 2120 |
if score >= 0.9:
|
| 2121 |
-
#
|
| 2122 |
-
|
| 2123 |
-
|
| 2124 |
-
|
|
|
|
|
|
|
| 2125 |
elif score >= 0.8:
|
| 2126 |
-
#
|
| 2127 |
-
|
| 2128 |
-
|
| 2129 |
-
|
|
|
|
|
|
|
| 2130 |
elif score >= 0.7:
|
| 2131 |
-
#
|
| 2132 |
-
|
| 2133 |
-
return
|
| 2134 |
-
|
|
|
|
| 2135 |
elif score >= 0.5:
|
| 2136 |
-
#
|
| 2137 |
position = (score - 0.5) / 0.2
|
| 2138 |
-
|
| 2139 |
-
|
| 2140 |
-
|
| 2141 |
else:
|
| 2142 |
-
#
|
|
|
|
| 2143 |
position = score / 0.5
|
| 2144 |
-
|
| 2145 |
-
return apply_distinction_factor(base, 0.02)
|
| 2146 |
|
| 2147 |
|
| 2148 |
# def amplify_score_extreme(score: float) -> float:
|
|
|
|
| 2102 |
|
| 2103 |
|
| 2104 |
def amplify_score_extreme(score: float) -> float:
|
| 2105 |
+
"""
|
| 2106 |
+
1. 提供更廣的分數範圍,讓優秀匹配能獲得更高分數
|
| 2107 |
+
2. 在各個分數區間保持平滑的轉換
|
| 2108 |
+
3. 確保即使是較低匹配也有參考價值
|
| 2109 |
+
4. 對所有情況都使用一致的評分標準
|
| 2110 |
"""
|
| 2111 |
def smooth_curve(x: float, steepness: float = 12) -> float:
|
| 2112 |
+
"""
|
| 2113 |
+
使用 sigmoid 曲線來實現平滑的分數轉換
|
| 2114 |
+
steepness 參數控制曲線的陡峭程度:
|
| 2115 |
+
- 較高的值會產生更陡峭的曲線
|
| 2116 |
+
- 較低的值會產生更平緩的曲線
|
| 2117 |
+
"""
|
| 2118 |
import math
|
| 2119 |
return 1 / (1 + math.exp(-steepness * (x - 0.5)))
|
| 2120 |
|
| 2121 |
+
# 處理最高分數範圍(原始分數 0.9-1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2122 |
if score >= 0.9:
|
| 2123 |
+
# 將 90-100% 的原始分數映射到 88-96% 的最終分數
|
| 2124 |
+
# 這確保了最佳匹配能獲得顯著高的分數,但仍保留改進空間
|
| 2125 |
+
position = (score - 0.9) / 0.1
|
| 2126 |
+
return 0.88 + (position * 0.08)
|
| 2127 |
+
|
| 2128 |
+
# 處理優秀分數範圍(原始分數 0.8-0.9)
|
| 2129 |
elif score >= 0.8:
|
| 2130 |
+
# 將 80-90% 的原始分數映射到 82-88% 的最終分數
|
| 2131 |
+
# 這個範圍表示非常好但不是完美的匹配
|
| 2132 |
+
position = (score - 0.8) / 0.1
|
| 2133 |
+
return 0.82 + (position * 0.06)
|
| 2134 |
+
|
| 2135 |
+
# 處理良好分數範圍(原始分數 0.7-0.8)
|
| 2136 |
elif score >= 0.7:
|
| 2137 |
+
# 將 70-80% 的原始分數映射到 76-82% 的最終分數
|
| 2138 |
+
position = (score - 0.7) / 0.1
|
| 2139 |
+
return 0.76 + (position * 0.06)
|
| 2140 |
+
|
| 2141 |
+
# 處理中等分數範圍(原始分數 0.5-0.7)
|
| 2142 |
elif score >= 0.5:
|
| 2143 |
+
# 使用平滑曲線將 50-70% 的原始分數映射到 70-76% 的最終分數
|
| 2144 |
position = (score - 0.5) / 0.2
|
| 2145 |
+
return 0.70 + (smooth_curve(position) * 0.06)
|
| 2146 |
+
|
| 2147 |
+
# 處理較低分數範圍(原始分數 < 0.5)
|
| 2148 |
else:
|
| 2149 |
+
# 使用平滑曲線將 0-50% 的原始分數映射到 65-70% 的最終分數
|
| 2150 |
+
# 即使是較差的匹配也保持基本的參考價值
|
| 2151 |
position = score / 0.5
|
| 2152 |
+
return 0.65 + (smooth_curve(position) * 0.05)
|
|
|
|
| 2153 |
|
| 2154 |
|
| 2155 |
# def amplify_score_extreme(score: float) -> float:
|