|
@@ -62,13 +62,20 @@ class Recommend:
|
|
|
# shop_data = self._dao.get_shop_by_ids(self._city_uuid, recall_cust_list)[ShopConfig.FEATURE_COLUMNS]
|
|
# shop_data = self._dao.get_shop_by_ids(self._city_uuid, recall_cust_list)[ShopConfig.FEATURE_COLUMNS]
|
|
|
cust_data = sample_data_clear(cust_data, CustConfig)
|
|
cust_data = sample_data_clear(cust_data, CustConfig)
|
|
|
# shop_data = sample_data_clear(shop_data, ShopConfig)
|
|
# shop_data = sample_data_clear(shop_data, ShopConfig)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# cust_feats = shop_data.set_index("cust_code")
|
|
# cust_feats = shop_data.set_index("cust_code")
|
|
|
# cust_data = cust_data.join(cust_feats, on="BB_RETAIL_CUSTOMER_CODE", how="inner")
|
|
# cust_data = cust_data.join(cust_feats, on="BB_RETAIL_CUSTOMER_CODE", how="inner")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # 按 recall_cust_list 顺序对齐 cust_data,确保 feats_map 行顺序与 recall_list 一致
|
|
|
|
|
+ # 否则 get_recommend_list 中 zip(recall_list, scores) 会错配商户ID和分数
|
|
|
|
|
+ cust_codes_in_data = set(cust_data["cust_code"].tolist())
|
|
|
|
|
+ ordered_recall_list = [c for c in recall_cust_list if c in cust_codes_in_data]
|
|
|
|
|
+ cust_order = {code: i for i, code in enumerate(ordered_recall_list)}
|
|
|
|
|
+ cust_data = cust_data.sort_values("cust_code", key=lambda x: x.map(cust_order)).reset_index(drop=True)
|
|
|
|
|
+
|
|
|
# 获取推理用的feats_map
|
|
# 获取推理用的feats_map
|
|
|
feats_map = generate_feats_map(product_data, cust_data)
|
|
feats_map = generate_feats_map(product_data, cust_data)
|
|
|
- recommend_list = self._gbdtlr_model.get_recommend_list(feats_map, recall_cust_list)
|
|
|
|
|
|
|
+ recommend_list = self._gbdtlr_model.get_recommend_list(feats_map, ordered_recall_list)
|
|
|
# recommend_list = self.filter_recommend_list(recommend_list)
|
|
# recommend_list = self.filter_recommend_list(recommend_list)
|
|
|
return recommend_list
|
|
return recommend_list
|
|
|
|
|
|