liqian 2 years ago
parent
commit
ede0148af9
2 changed files with 14 additions and 11 deletions
  1. 10 9
      ad_user_video_predict.py
  2. 4 2
      config.py

+ 10 - 9
ad_user_video_predict.py

@@ -107,18 +107,19 @@ def predict_ad_group_video(dt, config_key, config_param):
             key_name = f"{config_.KEY_NAME_PREFIX_AD_THRESHOLD}{abtest_id}:{abtest_config_tag}:{abtest_group}:{key}"
             redis_helper.set_data_to_redis(key_name=key_name, value=val, expire_time=2 * 24 * 3600)
 
-        # 计算比常态阈值较低阈值 并 写入Redis
-        up_threshold_flag = config_param.get('up_threshold_flag', None)
-        up_rate = config_param.get('up_rate', None)
-        if up_threshold_flag is True:
-            up_threshold_data = {}
+        # 计算关怀模式实验阈值 并 写入Redis
+        care_model = config_param.get('care_model', None)
+        threshold_rate = config_param.get('threshold_rate', None)
+        if care_model is True:
+            care_model_threshold_data = {}
             for key, val in threshold_data.items():
-                up_val = val * up_rate
-                up_threshold_data[key] = up_val
+                up_val = val * threshold_rate
+                care_model_threshold_data[key] = up_val
                 up_key_name = \
-                    f"{config_.KEY_NAME_PREFIX_AD_THRESHOLD}{abtest_id}:{abtest_config_tag}:{abtest_group}:{key}:up"
+                    f"{config_.KEY_NAME_PREFIX_AD_THRESHOLD_CARE_MODEL}{abtest_id}:{abtest_config_tag}:{abtest_group}:{key}"
                 redis_helper.set_data_to_redis(key_name=up_key_name, value=up_val, expire_time=2 * 24 * 3600)
-            log_.info(f"config_key = {config_key}, abtest_group = {abtest_group}, up_threshold_data = {up_threshold_data}")
+            log_.info(f"config_key = {config_key}, abtest_group = {abtest_group}, "
+                      f"care_model_threshold_data = {care_model_threshold_data}")
 
     # predict_df.to_csv(f'./data/ad_user_video_predict_{config_key}.csv')
     log_.info(f"config_key = {config_key} update end!")

+ 4 - 2
config.py

@@ -789,11 +789,11 @@ class BaseConfig(object):
                   'user': {'data': 'data1', 'rule': 'rule1'}},
         '173-e': {'video': {'data': 'data1'},
                   'user': {'data': 'data1', 'rule': 'rule2'},
-                  'up_threshold_flag': True, 'up_rate': 0.9,  # 存储比常态阈值较低阈值
+                  'care_model': True, 'threshold_rate': 0.9,  # 关怀模式实验阈值
                   },
         '173-f': {'video': {'data': 'data1'},
                   'user': {'data': 'data1', 'rule': 'rule2'},
-                  'up_threshold_flag': True, 'up_rate': 0.9,
+                  'care_model': True, 'threshold_rate': 0.9,
                   },
         # 票圈视频+
         '190-a': {'video': {'data': 'data1'},
@@ -999,6 +999,8 @@ class BaseConfig(object):
     KEY_NAME_PREFIX_MID_GROUP = 'mid:group:'
     # 广告推荐阈值结果存放 redis key 前缀,完整格式:ad:threshold:{abtestId}:{abtestConfigTag}:{abtestGroup}:{group}
     KEY_NAME_PREFIX_AD_THRESHOLD = 'ad:threshold:'
+    # 广告推荐关怀模式实验阈值结果存放 redis key 前缀,完整格式:ad:threshold:care:{abtestId}:{abtestConfigTag}:{abtestGroup}:{group}
+    KEY_NAME_PREFIX_AD_THRESHOLD_CARE_MODEL = 'ad:threshold:care:'
     # 广告推荐阈值计算记录存放 redis key,完整格式:ad:threshold:record
     KEY_NAME_PREFIX_AD_THRESHOLD_RECORD = 'ad:threshold:record'