Ver Fonte

update target_uv_param config

liqian há 2 anos atrás
pai
commit
ab566b47c8
2 ficheiros alterados com 53 adições e 25 exclusões
  1. 43 23
      ad_threshold_auto_update.py
  2. 10 2
      config.py

+ 43 - 23
ad_threshold_auto_update.py

@@ -82,6 +82,7 @@ def get_threshold_record_new_by_uv(ad_abtest_abcode_config, feature_df, threshol
         for ab_test_group, target_uv in target_uv_mapping.items():
             if target_uv is None:
                 continue
+            gradient, max_update_step = get_ad_uv_update_config(app_type=app_type, ab_group=ab_test_group)
             update_range = threshold_update_mapping.get(ab_test_group)
             # 获取对应组的当前uv
             try:
@@ -112,29 +113,30 @@ def get_threshold_record_new_by_uv(ad_abtest_abcode_config, feature_df, threshol
                 threshold_param_new = float(threshold_param_old) + update_range * step
             else:
                 continue
-            if threshold_param_new > 0:
-                log_.info(
-                    {
-                        'appType': app_type, 'abtestid': ab_test_id, 'abTestGroup': ab_test_group,
-                        'targetUv': target_uv, 'currentUv': round(current_uv, 4),
-                        'uvDiffer':  round(uv_differ, 4), 'gradient': round(gradient, 4), 'step': step,
-                        'range': round(update_range, 4),
-                        'paramOld': round(float(threshold_param_old), 4),
-                        'paramNew': round(threshold_param_new, 4)
-                    }
-                )
-                threshold_record_new[ab_test_id][ab_test_group]['group'] = threshold_param_new
-                threshold_record_new[ab_test_id][ab_test_group]['mean_group'] = threshold_param_new
-                robot_msg_record.append(
-                    {
-                        'appType': app_type, 'abtestid': ab_test_id, 'abTestGroup': ab_test_group,
-                        'targetUv': target_uv, 'currentUv': round(current_uv, 4),
-                        'uvDiffer':  round(uv_differ, 4), 'gradient': round(gradient, 4), 'step': step,
-                        'range': round(update_range, 4),
-                        'paramOld': round(float(threshold_param_old), 4),
-                        'paramNew': round(threshold_param_new, 4)
-                    }
-                )
+            if threshold_param_new <= 0:
+                threshold_param_new = 0
+            log_.info(
+                {
+                    'appType': app_type, 'abtestid': ab_test_id, 'abTestGroup': ab_test_group,
+                    'targetUv': target_uv, 'currentUv': round(current_uv, 4),
+                    'uvDiffer':  round(uv_differ, 4), 'gradient': round(gradient, 4), 'step': step,
+                    'range': round(update_range, 4),
+                    'paramOld': round(float(threshold_param_old), 4),
+                    'paramNew': round(threshold_param_new, 4)
+                }
+            )
+            threshold_record_new[ab_test_id][ab_test_group]['group'] = threshold_param_new
+            threshold_record_new[ab_test_id][ab_test_group]['mean_group'] = threshold_param_new
+            robot_msg_record.append(
+                {
+                    'appType': app_type, 'abtestid': ab_test_id, 'abTestGroup': ab_test_group,
+                    'targetUv': target_uv, 'currentUv': round(current_uv, 4),
+                    'uvDiffer':  round(uv_differ, 4), 'gradient': round(gradient, 4), 'step': step,
+                    'range': round(update_range, 4),
+                    'paramOld': round(float(threshold_param_old), 4),
+                    'paramNew': round(threshold_param_new, 4)
+                }
+            )
     return threshold_record_new, robot_msg_record
 
 
@@ -256,6 +258,24 @@ def get_ad_target_uv(now_h):
     return ad_target_uv
 
 
+def get_ad_uv_update_config(app_type, ab_group):
+    """获取对应组自动调整阈值参数:梯度,最大步长"""
+    now_h = datetime.datetime.now().hour
+    update_threshold_params = config_.AD_ABTEST_ABCODE_CONFIG.get(int(app_type))
+    gradient = update_threshold_params.get('gradient')
+    max_update_step = update_threshold_params.get('max_update_step')
+    target_uv_param = update_threshold_params.get('target_uv_param', {})
+    target_uv_param_group = target_uv_param.get(ab_group, None)
+    if target_uv_param_group is not None:
+        special_update_config = target_uv_param_group.get('special_update_config', None)
+        if special_update_config is not None:
+            special_hours = special_update_config.get('special_hours', [])
+            if now_h in special_hours:
+                gradient = special_update_config.get('special_gradient')
+                max_update_step = special_update_config.get('special_max_update_step')
+    return gradient, max_update_step
+
+
 def timer_check():
     try:
         # 获取自动调整阈值参数

+ 10 - 2
config.py

@@ -1075,8 +1075,16 @@ class BaseConfig(object):
             },
             # 分时段控制目标uv参数
             'target_uv_param': {
-                'ab5': {'update_hours': list(range(10)), 'update_param': 0},  # 0-10点,uv控制在0%
-                'ab6': {'update_hours': list(range(10)), 'update_param': 1/2},  # 0-10点,uv控制在设定目标uv的1/2
+                'ab5': {
+                    'update_hours': list(range(9)), 'update_param': 0,
+                    'special_update_config': {'special_hours': [0, 1, 2, 9], 'special_gradient': 0.02,
+                                              'special_max_update_step': 15}
+                },  # 0-10点,uv控制在0%
+                'ab6': {
+                    'update_hours': list(range(9)), 'update_param': 1/2,
+                    'special_update_config': {'special_hours': [0, 1, 2, 9], 'special_gradient': 0.02,
+                                              'special_max_update_step': 10}
+                },  # 0-10点,uv控制在设定目标uv的1/2
             }
         },
         # 票圈视频+