Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +23 -25
scoring_calculation_system.py
CHANGED
@@ -2137,19 +2137,29 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2137 |
return multiplier
|
2138 |
|
2139 |
def evaluate_breed_specific_requirements():
|
2140 |
-
"""
|
2141 |
multiplier = 1.0
|
2142 |
exercise_time = user_prefs.exercise_time
|
2143 |
exercise_type = user_prefs.exercise_type
|
2144 |
|
2145 |
-
#
|
2146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2147 |
if exercise_time > 120 and exercise_type != 'active_training':
|
2148 |
-
multiplier *= 0.7
|
2149 |
|
2150 |
-
|
2151 |
-
if any(trait in breed_info.get('Temperament', '').lower()
|
2152 |
-
for trait in ['working', 'herding']):
|
2153 |
if exercise_time < 90 or exercise_type == 'light_walks':
|
2154 |
multiplier *= 0.7
|
2155 |
|
@@ -2319,42 +2329,30 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2319 |
|
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.
|
2338 |
|
2339 |
-
# 處理優秀匹配:提供更高的基準分數
|
2340 |
elif score >= 0.8:
|
2341 |
position = (score - 0.8) / 0.1
|
2342 |
-
return 0.
|
2343 |
|
2344 |
-
# 處理良好匹配:確保合格的配對有好的分數
|
2345 |
elif score >= 0.7:
|
2346 |
position = (score - 0.7) / 0.1
|
2347 |
-
return 0.
|
2348 |
|
2349 |
-
# 處理一般匹配:給予合理的參考分數
|
2350 |
elif score >= 0.5:
|
2351 |
position = (score - 0.5) / 0.2
|
2352 |
-
return 0.
|
2353 |
|
2354 |
-
# 處理較低匹配:保持參考價值
|
2355 |
else:
|
2356 |
position = score / 0.5
|
2357 |
-
return 0.
|
2358 |
|
2359 |
|
2360 |
# def amplify_score_extreme(score: float) -> float:
|
|
|
2137 |
return multiplier
|
2138 |
|
2139 |
def evaluate_breed_specific_requirements():
|
2140 |
+
"""評估品種特定的要求,加強運動需求的判斷"""
|
2141 |
multiplier = 1.0
|
2142 |
exercise_time = user_prefs.exercise_time
|
2143 |
exercise_type = user_prefs.exercise_type
|
2144 |
|
2145 |
+
# 檢查品種的基本特性
|
2146 |
+
temperament = breed_info.get('Temperament', '').lower()
|
2147 |
+
description = breed_info.get('Description', '').lower()
|
2148 |
+
exercise_needs = breed_info.get('Exercise Needs', 'MODERATE').upper()
|
2149 |
+
|
2150 |
+
# 加強運動需求的匹配判斷
|
2151 |
+
if exercise_needs == 'LOW':
|
2152 |
+
if exercise_time > 90: # 如果用戶運動時間過長
|
2153 |
+
multiplier *= 0.5 # 給予更強的懲罰
|
2154 |
+
elif exercise_needs == 'VERY HIGH':
|
2155 |
+
if exercise_time < 60: # 如果用戶運動時間過短
|
2156 |
+
multiplier *= 0.5
|
2157 |
+
|
2158 |
+
if 'sprint' in temperament:
|
2159 |
if exercise_time > 120 and exercise_type != 'active_training':
|
2160 |
+
multiplier *= 0.7
|
2161 |
|
2162 |
+
if any(trait in temperament for trait in ['working', 'herding']):
|
|
|
|
|
2163 |
if exercise_time < 90 or exercise_type == 'light_walks':
|
2164 |
multiplier *= 0.7
|
2165 |
|
|
|
2329 |
|
2330 |
|
2331 |
def amplify_score_extreme(score: float) -> float:
|
2332 |
+
"""優化分數分布,提供更高的分數範圍"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2333 |
def smooth_curve(x: float, steepness: float = 12) -> float:
|
2334 |
import math
|
2335 |
return 1 / (1 + math.exp(-steepness * (x - 0.5)))
|
2336 |
|
|
|
2337 |
if score >= 0.9:
|
2338 |
position = (score - 0.9) / 0.1
|
2339 |
+
return 0.96 + (position * 0.04) # 90-100的原始分映射到96-100
|
2340 |
|
|
|
2341 |
elif score >= 0.8:
|
2342 |
position = (score - 0.8) / 0.1
|
2343 |
+
return 0.90 + (position * 0.06) # 80-90的原始分映射到90-96
|
2344 |
|
|
|
2345 |
elif score >= 0.7:
|
2346 |
position = (score - 0.7) / 0.1
|
2347 |
+
return 0.82 + (position * 0.08) # 70-80的原始分映射到82-90
|
2348 |
|
|
|
2349 |
elif score >= 0.5:
|
2350 |
position = (score - 0.5) / 0.2
|
2351 |
+
return 0.75 + (smooth_curve(position) * 0.07) # 50-70的原始分映射到75-82
|
2352 |
|
|
|
2353 |
else:
|
2354 |
position = score / 0.5
|
2355 |
+
return 0.70 + (smooth_curve(position) * 0.05) # 50以下的原始分映射到70-75
|
2356 |
|
2357 |
|
2358 |
# def amplify_score_extreme(score: float) -> float:
|