|
@@ -39,7 +39,7 @@ def get_recall_cust(city_uuid, product_id, recall_count):
|
|
|
|
|
|
|
|
def generate_recommend_sample(city_uuid, product_id):
|
|
def generate_recommend_sample(city_uuid, product_id):
|
|
|
"""生成预测数据集"""
|
|
"""生成预测数据集"""
|
|
|
- recall_count = 300
|
|
|
|
|
|
|
+ recall_count = 1000
|
|
|
cust_list = get_recall_cust(city_uuid, product_id, recall_count)
|
|
cust_list = get_recall_cust(city_uuid, product_id, recall_count)
|
|
|
|
|
|
|
|
product_data = dao.get_product_by_id(city_uuid, product_id)[ProductConfig.FEATURE_COLUMNS]
|
|
product_data = dao.get_product_by_id(city_uuid, product_id)[ProductConfig.FEATURE_COLUMNS]
|
|
@@ -83,7 +83,7 @@ def run():
|
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
- # generate_features_shap("00000000000000000000000011445301", "420202", delivery_count=5000)
|
|
|
|
|
|
|
+ generate_features_shap("00000000000000000000000011445301", "420202", delivery_count=5000)
|
|
|
# recommend_list = get_recommend_list("00000000000000000000000011445301", "420202")
|
|
# recommend_list = get_recommend_list("00000000000000000000000011445301", "420202")
|
|
|
# recommend_list = pd.DataFrame(recommend_list)
|
|
# recommend_list = pd.DataFrame(recommend_list)
|
|
|
# recommend_list.to_csv("./data/recommend_list.csv", index=False, encoding="utf-8-sig")
|
|
# recommend_list.to_csv("./data/recommend_list.csv", index=False, encoding="utf-8-sig")
|
|
@@ -93,24 +93,24 @@ if __name__ == '__main__':
|
|
|
# data = data.groupby(["cust_code", "product_code", "product_name"], as_index=False)["sale_qty"].sum()
|
|
# data = data.groupby(["cust_code", "product_code", "product_name"], as_index=False)["sale_qty"].sum()
|
|
|
# data.to_csv("./data/cust.csv", index=False)
|
|
# data.to_csv("./data/cust.csv", index=False)
|
|
|
|
|
|
|
|
- city_uuid = "00000000000000000000000011445301"
|
|
|
|
|
- order_data = dao.get_order_by_cust("00000000000000000000000011445301", "445323105795")
|
|
|
|
|
- order_data["sale_qty"] = order_data["sale_qty"].fillna(0)
|
|
|
|
|
- order_data = order_data.infer_objects(copy=False)
|
|
|
|
|
- order_data = order_data.groupby(["cust_code", "product_code", "product_name"], as_index=False)["sale_qty"].sum()
|
|
|
|
|
|
|
+ # city_uuid = "00000000000000000000000011445301"
|
|
|
|
|
+ # order_data = dao.get_order_by_cust("00000000000000000000000011445301", "445323105795")
|
|
|
|
|
+ # order_data["sale_qty"] = order_data["sale_qty"].fillna(0)
|
|
|
|
|
+ # order_data = order_data.infer_objects(copy=False)
|
|
|
|
|
+ # order_data = order_data.groupby(["cust_code", "product_code", "product_name"], as_index=False)["sale_qty"].sum()
|
|
|
|
|
|
|
|
- cust_data = dao.load_cust_data(city_uuid)[CustConfig.FEATURE_COLUMNS]
|
|
|
|
|
- sample_data_clear(cust_data, CustConfig)
|
|
|
|
|
- shop_data = dao.load_shopping_data(city_uuid)[ShopConfig.FEATURE_COLUMNS]
|
|
|
|
|
- sample_data_clear(shop_data, ShopConfig)
|
|
|
|
|
- cust_ids = shop_data.set_index("cust_code")
|
|
|
|
|
- cust_data = cust_data.join(cust_ids, on="BB_RETAIL_CUSTOMER_CODE", how="inner")
|
|
|
|
|
|
|
+ # cust_data = dao.load_cust_data(city_uuid)[CustConfig.FEATURE_COLUMNS]
|
|
|
|
|
+ # sample_data_clear(cust_data, CustConfig)
|
|
|
|
|
+ # shop_data = dao.load_shopping_data(city_uuid)[ShopConfig.FEATURE_COLUMNS]
|
|
|
|
|
+ # sample_data_clear(shop_data, ShopConfig)
|
|
|
|
|
+ # cust_ids = shop_data.set_index("cust_code")
|
|
|
|
|
+ # cust_data = cust_data.join(cust_ids, on="BB_RETAIL_CUSTOMER_CODE", how="inner")
|
|
|
|
|
|
|
|
- product_data = dao.load_product_data(city_uuid)[ProductConfig.FEATURE_COLUMNS]
|
|
|
|
|
- sample_data_clear(product_data, ProductConfig)
|
|
|
|
|
|
|
+ # product_data = dao.load_product_data(city_uuid)[ProductConfig.FEATURE_COLUMNS]
|
|
|
|
|
+ # sample_data_clear(product_data, ProductConfig)
|
|
|
|
|
|
|
|
- order_data = order_data.merge(product_data, on="product_code", how="inner")
|
|
|
|
|
- order_data = order_data.merge(cust_data, left_on='cust_code', right_on='BB_RETAIL_CUSTOMER_CODE', how="inner")
|
|
|
|
|
|
|
+ # order_data = order_data.merge(product_data, on="product_code", how="inner")
|
|
|
|
|
+ # order_data = order_data.merge(cust_data, left_on='cust_code', right_on='BB_RETAIL_CUSTOMER_CODE', how="inner")
|
|
|
|
|
|
|
|
- result = gbdtlr_model.inference_from_sample(order_data)
|
|
|
|
|
- result.to_csv("./data/junlong.csv", index=False)
|
|
|
|
|
|
|
+ # result = gbdtlr_model.inference_from_sample(order_data)
|
|
|
|
|
+ # result.to_csv("./data/junlong.csv", index=False)
|