SPB Git

spb/resto-ka

Public

Resto·Ka — tous les restaurants du Québec, menus complets et prix réels (famille ·Ka)

feat(ka-id v2.2): boost COLLABORATIVE_MODEL des recommandations du modèle ALS (kaid.py aligné sur ka-ui.git/kaid f844854)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Simon-Pierre Boucher committed (Aug 26, 2026) parent 53e215a Browse files

1 changed file +8 −2

Unified Split
modified restoka/kaid.py +8 −2
@@ -292,8 +292,10 @@ def rerank(items: list, user, *, features_of, uid_of=None,
292 tail = items[max_considered:] 292 tail = items[max_considered:]
293 n = len(head) 293 n = len(head)
294 active = active_dims or set() 294 active = active_dims or set()
295− # co-favoris des membres semblables (filtrage collaboratif du hub) 295+ # signaux collaboratifs du hub : co-favoris (item-item) et
296+ # recommandations du modèle de matrix factorization (ALS, batch quotidien)
296 similar = {str(s) for s in (app_p.get("similar") or [])} 297 similar = {str(s) for s in (app_p.get("similar") or [])}
298+ mf = {str(s) for s in (app_p.get("mf") or [])}
297 scored = [] 299 scored = []
298 badged = 0 300 badged = 0
299 for i, it in enumerate(head): 301 for i, it in enumerate(head):
@@ -303,9 +305,13 @@ def rerank(items: list, user, *, features_of, uid_of=None,
303 profile.get("global") or {}, active) 305 profile.get("global") or {}, active)
304 except Exception: 306 except Exception:
305 p, reasons = None, [] 307 p, reasons = None, []
306− if similar and str(uid_of(it)) in similar: 308+ uid = str(uid_of(it))
309+ if similar and uid in similar:
307 p = min(1.0, (p if p is not None else 0.55) + 0.25) 310 p = min(1.0, (p if p is not None else 0.55) + 0.25)
308 reasons = (["SIMILAR_USERS"] + reasons)[:4] 311 reasons = (["SIMILAR_USERS"] + reasons)[:4]
312+ elif mf and uid in mf:
313+ p = min(1.0, (p if p is not None else 0.55) + 0.25)
314+ reasons = (["COLLABORATIVE_MODEL"] + reasons)[:4]
309 if p is None: 315 if p is None:
310 final = (1.0 - blend) * base + blend * 0.5 316 final = (1.0 - blend) * base + blend * 0.5
311 else: 317 else:
312 318
Menu

Theme