Ver Fonte

update step computing method

liqian há 2 anos atrás
pai
commit
22f4dd7e0a
1 ficheiros alterados com 10 adições e 4 exclusões
  1. 10 4
      ad_threshold_auto_update.py

+ 10 - 4
ad_threshold_auto_update.py

@@ -95,13 +95,19 @@ def get_threshold_record_new_by_uv(ad_abtest_abcode_config, feature_df, threshol
             # 获取当前阈值参数
             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: