|
@@ -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
|