|
@@ -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:
|
|
|
# 获取自动调整阈值参数
|