Преглед изворни кода

update ad abtest threshold auto update

liqian пре 2 година
родитељ
комит
25997aba9d
2 измењених фајлова са 14 додато и 8 уклоњено
  1. 12 7
      ad_threshold_auto_update.py
  2. 2 1
      config.py

+ 12 - 7
ad_threshold_auto_update.py

@@ -31,7 +31,8 @@ def get_threshold_record_new(ad_abtest_abcode_config, feature_df, threshold_reco
         temp_df = feature_df[feature_df['apptype'] == app_type]
         ab_test_id = config_params.get('ab_test_id')
         ab_test_config = config_params.get('ab_test_config')
-        threshold_update = config_params.get('threshold_update')
+        up_threshold_update = config_params.get('up_threshold_update')
+        down_threshold_update = config_params.get('down_threshold_update')
         for config_name, ab_code_list in ab_test_config.items():
             ad_abtest_tag = f"{ab_test_id}-{config_name}"
             # log_.info(f"ad_abtest_tag = {ad_abtest_tag}")
@@ -39,18 +40,22 @@ def get_threshold_record_new(ad_abtest_abcode_config, feature_df, threshold_reco
                 b_mean = temp_df[temp_df['adcode'].isin(ab_code_list)]['b'].mean()
                 if b_mean < 0:
                     # 阈值按梯度调高
-                    b_i = (b_mean * -1)//0.05 + 1
-                    threshold_param_new = float(threshold_record.get(ad_abtest_tag)) + threshold_update * b_i
+                    gradient = up_threshold_update.get('gradient')
+                    update_range = up_threshold_update.get('update_range')
+                    b_i = (b_mean * -1) // gradient + 1
+                    threshold_param_new = \
+                        float(threshold_record.get(ad_abtest_tag)) + update_range * b_i
                 elif b_mean > 0.1:
-                    # 阈值调低
-                    threshold_param_new = float(threshold_record.get(ad_abtest_tag)) - threshold_update
-                    b_i = 1
+                    # 阈值按梯度调低
+                    b_i = (b_mean - 0.1) // up_threshold_update.get('gradient') + 1
+                    threshold_param_new = \
+                        float(threshold_record.get(ad_abtest_tag)) - up_threshold_update.get('update_range') * b_i
                 else:
                     continue
                 if threshold_param_new > 0:
                     threshold_record_new[ad_abtest_tag] = threshold_param_new
                     robot_msg_record.append({'appType': app_type, 'ad_abtest_tag': ad_abtest_tag,
-                                             'b_i': int(b_i), 'gradient': round(threshold_update, 4),
+                                             'b_i': int(b_i), 'update_param':
                                              'param_old': round(float(threshold_record.get(ad_abtest_tag)), 4),
                                              'param_new': round(threshold_param_new, 4)})
     return threshold_record_new, robot_msg_record

+ 2 - 1
config.py

@@ -833,7 +833,8 @@ class BaseConfig(object):
         APP_TYPE['LOVE_LIVE']: {
             'ab_test_id': 194,
             'ab_test_config': {"a": ["ab6", "ab7", "ab8"], "b": ["ab3", "ab4"], "c": ["ab2"], "d": ["ab1"]},
-            'threshold_update': 1 / 24,
+            'up_threshold_update': {'gradient': 0.05, 'update_range': 1 / 24},
+            'down_threshold_update': {'gradient': 0.1, 'update_range': 1 / 12},
         },
         # 内容精选
         # APP_TYPE['LONG_VIDEO']: {