Spaces:
Running
on
Zero
Running
on
Zero
Update breed_recommendation.py
Browse files- breed_recommendation.py +0 -58
breed_recommendation.py
CHANGED
@@ -215,64 +215,6 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
215 |
error_msg = f"Error processing your description. Details: {str(e)}"
|
216 |
return [gr.update(value=error_msg), gr.update(visible=False)]
|
217 |
|
218 |
-
# # 最終分數計算
|
219 |
-
# is_preferred = smart_rec.get('is_preferred', False)
|
220 |
-
# base_score = compatibility_scores.get('overall', 0.7)
|
221 |
-
# smart_score = smart_rec['score']
|
222 |
-
|
223 |
-
# # 根據是否為偏好品種調整分數
|
224 |
-
# if is_preferred:
|
225 |
-
# final_score = 0.95 # 確保最高分
|
226 |
-
# else:
|
227 |
-
# # 相似品種的分數計算
|
228 |
-
# final_score = min(0.90, (base_score * 0.6 + smart_score * 0.4))
|
229 |
-
|
230 |
-
# final_recommendations.append({
|
231 |
-
# 'rank': 0, # 稍後更新
|
232 |
-
# 'breed': breed_name,
|
233 |
-
# 'base_score': round(base_score, 4),
|
234 |
-
# 'smart_match_score': round(smart_score, 4),
|
235 |
-
# 'final_score': round(final_score, 4),
|
236 |
-
# 'scores': compatibility_scores,
|
237 |
-
# 'match_reason': smart_rec['reason'],
|
238 |
-
# 'info': breed_info,
|
239 |
-
# 'noise_info': breed_noise_info.get(breed_name, {}),
|
240 |
-
# 'health_info': breed_health_info.get(breed_name, {})
|
241 |
-
# })
|
242 |
-
|
243 |
-
# # 根據final_score重新排序
|
244 |
-
# final_recommendations.sort(key=lambda x: (-x['final_score'], x['breed']))
|
245 |
-
|
246 |
-
# # 更新排名
|
247 |
-
# for i, rec in enumerate(final_recommendations, 1):
|
248 |
-
# rec['rank'] = i
|
249 |
-
|
250 |
-
# # 驗證排序
|
251 |
-
# print("\nFinal Rankings:")
|
252 |
-
# for rec in final_recommendations:
|
253 |
-
# print(f"#{rec['rank']} {rec['breed']}")
|
254 |
-
# print(f"Base Score: {rec['base_score']:.4f}")
|
255 |
-
# print(f"Smart Match Score: {rec['smart_match_score']:.4f}")
|
256 |
-
# print(f"Final Score: {rec['final_score']:.4f}")
|
257 |
-
# print(f"Reason: {rec['match_reason']}\n")
|
258 |
-
|
259 |
-
# # 確保分數按降序排列
|
260 |
-
# if rec['rank'] > 1:
|
261 |
-
# prev_score = final_recommendations[rec['rank']-2]['final_score']
|
262 |
-
# if rec['final_score'] > prev_score:
|
263 |
-
# print(f"Warning: Ranking inconsistency detected!")
|
264 |
-
# print(f"#{rec['rank']-1} score: {prev_score:.4f}")
|
265 |
-
# print(f"#{rec['rank']} score: {rec['final_score']:.4f}")
|
266 |
-
|
267 |
-
# result = format_recommendation_html(final_recommendations)
|
268 |
-
# return [gr.update(value=result), gr.update(visible=False)]
|
269 |
-
|
270 |
-
|
271 |
-
# except Exception as e:
|
272 |
-
# error_msg = f"Error processing your description. Details: {str(e)}"
|
273 |
-
# return [gr.update(value=error_msg), gr.update(visible=False)]
|
274 |
-
|
275 |
-
|
276 |
def show_loading():
|
277 |
return [gr.update(value=""), gr.update(visible=True)]
|
278 |
|
|
|
215 |
error_msg = f"Error processing your description. Details: {str(e)}"
|
216 |
return [gr.update(value=error_msg), gr.update(visible=False)]
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
def show_loading():
|
219 |
return [gr.update(value=""), gr.update(visible=True)]
|
220 |
|