소스 검색

Merge branch 'ad-abtest-threshold-auto-update-2023011110' into test

liqian 2 년 전
부모
커밋
a1aafb8a6d
1개의 변경된 파일11개의 추가작업 그리고 5개의 파일을 삭제
  1. 11 5
      ad_threshold_auto_update.py

+ 11 - 5
ad_threshold_auto_update.py

@@ -90,18 +90,24 @@ def get_threshold_record_new_by_uv(ad_abtest_abcode_config, feature_df, threshol
                 continue
             # 计算uv差值
             uv_differ = current_uv - target_uv
-            if abs(uv_differ) < not_update:
+            if abs(uv_differ) <= not_update:
                 continue
             # 获取当前阈值参数
             threshold_param_old = threshold_record_old[ab_test_group].get('group')
             if uv_differ < 0:
-                # 当前uv < 目标uv,阈值按梯度调低
-                step = math.ceil((uv_differ * -1) / gradient)
+                # 当前uv < 目标uv,阈值按梯度调低(第一个梯度区间:向上取整,之后:四舍五入)
+                if abs(uv_differ) < gradient:
+                    step = math.ceil(abs(uv_differ) / gradient)
+                else:
+                    step = round(abs(uv_differ) / gradient)
                 step = max_update_step if step > max_update_step else step
                 threshold_param_new = float(threshold_param_old) - update_range * step
             elif uv_differ > 0:
-                # 当前uv > 目标uv,阈值按梯度调高
-                step = math.ceil(uv_differ / gradient)
+                # 当前uv > 目标uv,阈值按梯度调高(第一个梯度区间:向上取整,之后:四舍五入)
+                if uv_differ < gradient:
+                    step = math.ceil(uv_differ / gradient)
+                else:
+                    step = round(uv_differ / gradient)
                 step = max_update_step if step > max_update_step else step
                 threshold_param_new = float(threshold_param_old) + update_range * step
             else: