Spaces:
Sleeping
Sleeping
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +15 -14
scoring_calculation_system.py
CHANGED
@@ -2320,40 +2320,41 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2320 |
|
2321 |
def amplify_score_extreme(score: float) -> float:
|
2322 |
"""
|
2323 |
-
|
2324 |
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
- 50-70的原始分數會被映射到70-78%
|
2330 |
-
- 50以下的原始分數會被映射到60-70%
|
2331 |
-
|
2332 |
-
使用sigmoid曲線來平滑較低分數的轉換,避免突兀的分數跳變
|
2333 |
"""
|
2334 |
def smooth_curve(x: float, steepness: float = 12) -> float:
|
2335 |
import math
|
2336 |
return 1 / (1 + math.exp(-steepness * (x - 0.5)))
|
2337 |
|
|
|
2338 |
if score >= 0.9:
|
2339 |
position = (score - 0.9) / 0.1
|
2340 |
-
return 0.
|
2341 |
|
|
|
2342 |
elif score >= 0.8:
|
2343 |
position = (score - 0.8) / 0.1
|
2344 |
-
return 0.
|
2345 |
|
|
|
2346 |
elif score >= 0.7:
|
2347 |
position = (score - 0.7) / 0.1
|
2348 |
-
return 0.
|
2349 |
|
|
|
2350 |
elif score >= 0.5:
|
2351 |
position = (score - 0.5) / 0.2
|
2352 |
-
return 0.
|
2353 |
|
|
|
2354 |
else:
|
2355 |
position = score / 0.5
|
2356 |
-
return 0.
|
2357 |
|
2358 |
|
2359 |
# def amplify_score_extreme(score: float) -> float:
|
|
|
2320 |
|
2321 |
def amplify_score_extreme(score: float) -> float:
|
2322 |
"""
|
2323 |
+
優化分數分布以提供更有意義的評分範圍
|
2324 |
|
2325 |
+
這個函數的設計理念是:
|
2326 |
+
1. 讓優秀的匹配能得到90%以上的高分
|
2327 |
+
2. 保持合理的分數差異
|
2328 |
+
3. 確保即使是較低匹配也有參考價值
|
|
|
|
|
|
|
|
|
2329 |
"""
|
2330 |
def smooth_curve(x: float, steepness: float = 12) -> float:
|
2331 |
import math
|
2332 |
return 1 / (1 + math.exp(-steepness * (x - 0.5)))
|
2333 |
|
2334 |
+
# 處理最佳匹配:讓頂級匹配能達到95%以上
|
2335 |
if score >= 0.9:
|
2336 |
position = (score - 0.9) / 0.1
|
2337 |
+
return 0.95 + (position * 0.05) # 90-100的原始分映射到95-100
|
2338 |
|
2339 |
+
# 處理優秀匹配:提供更高的基準分數
|
2340 |
elif score >= 0.8:
|
2341 |
position = (score - 0.8) / 0.1
|
2342 |
+
return 0.88 + (position * 0.07) # 80-90的原始分映射到88-95
|
2343 |
|
2344 |
+
# 處理良好匹配:確保合格的配對有好的分數
|
2345 |
elif score >= 0.7:
|
2346 |
position = (score - 0.7) / 0.1
|
2347 |
+
return 0.80 + (position * 0.08) # 70-80的原始分映射到80-88
|
2348 |
|
2349 |
+
# 處理一般匹配:給予合理的參考分數
|
2350 |
elif score >= 0.5:
|
2351 |
position = (score - 0.5) / 0.2
|
2352 |
+
return 0.70 + (smooth_curve(position) * 0.10) # 50-70的原始分映射到70-80
|
2353 |
|
2354 |
+
# 處理較低匹配:保持參考價值
|
2355 |
else:
|
2356 |
position = score / 0.5
|
2357 |
+
return 0.65 + (smooth_curve(position) * 0.05) # 50以下的原始分映射到65-70
|
2358 |
|
2359 |
|
2360 |
# def amplify_score_extreme(score: float) -> float:
|