Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +33 -17
scoring_calculation_system.py
CHANGED
@@ -943,27 +943,43 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
943 |
if user_prefs.has_children:
|
944 |
family_safety = calculate_family_safety_score(breed_info, user_prefs.children_age)
|
945 |
|
946 |
-
#
|
947 |
-
|
948 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
949 |
|
950 |
-
|
951 |
-
scores['experience'] *= (0.6 + (family_safety * 0.4))
|
952 |
|
953 |
-
#
|
954 |
-
|
|
|
955 |
|
956 |
-
#
|
957 |
-
|
958 |
-
|
959 |
-
|
|
|
|
|
|
|
|
|
960 |
weighted_score = sum(score * weights[category] for category, score in scores.items())
|
961 |
-
|
962 |
-
# 加入品種額外加分的影響
|
963 |
-
breed_bonus = calculate_breed_bonus(breed_info, user_prefs)
|
964 |
-
# 如果有孩童,品種加分的影響要考慮家庭因素
|
965 |
-
if user_prefs.has_children:
|
966 |
-
breed_bonus *= family_safety
|
967 |
weighted_score *= (1 + breed_bonus * 0.2)
|
968 |
|
969 |
def amplify_score(score):
|
|
|
943 |
if user_prefs.has_children:
|
944 |
family_safety = calculate_family_safety_score(breed_info, user_prefs.children_age)
|
945 |
|
946 |
+
# 根據孩童年齡設定不同的調整強度
|
947 |
+
age_adjustments = {
|
948 |
+
'toddler': {
|
949 |
+
'space': (0.5, 0.5), # (基礎係數, 安全係數權重)
|
950 |
+
'experience': (0.4, 0.6), # 幼童需要更嚴格的經驗要求
|
951 |
+
'exercise': (0.6, 0.4),
|
952 |
+
'noise': (0.5, 0.5)
|
953 |
+
},
|
954 |
+
'school_age': {
|
955 |
+
'space': (0.6, 0.4),
|
956 |
+
'experience': (0.5, 0.5),
|
957 |
+
'exercise': (0.7, 0.3),
|
958 |
+
'noise': (0.6, 0.4)
|
959 |
+
},
|
960 |
+
'teenager': {
|
961 |
+
'space': (0.7, 0.3),
|
962 |
+
'experience': (0.6, 0.4),
|
963 |
+
'exercise': (0.8, 0.2),
|
964 |
+
'noise': (0.7, 0.3)
|
965 |
+
}
|
966 |
+
}
|
967 |
|
968 |
+
adjustments = age_adjustments[user_prefs.children_age]
|
|
|
969 |
|
970 |
+
# 應用更嚴格的調整
|
971 |
+
for category, (base_coef, safety_weight) in adjustments.items():
|
972 |
+
scores[category] *= (base_coef + (family_safety * safety_weight))
|
973 |
|
974 |
+
# 品種加分也需要根據年齡組進行調整
|
975 |
+
breed_bonus_adjustments = {
|
976 |
+
'toddler': 0.4, # 幼童情況下品種加分影響最小
|
977 |
+
'school_age': 0.6,
|
978 |
+
'teenager': 0.8
|
979 |
+
}
|
980 |
+
breed_bonus *= (breed_bonus_adjustments[user_prefs.children_age] * family_safety)
|
981 |
+
|
982 |
weighted_score = sum(score * weights[category] for category, score in scores.items())
|
|
|
|
|
|
|
|
|
|
|
|
|
983 |
weighted_score *= (1 + breed_bonus * 0.2)
|
984 |
|
985 |
def amplify_score(score):
|