liqian 2 years ago
parent
commit
d5b2661fb4
1 changed files with 10 additions and 9 deletions
  1. 10 9
      ad_threshold_auto_update.py

+ 10 - 9
ad_threshold_auto_update.py

@@ -43,21 +43,22 @@ def get_threshold_record_new(ad_abtest_abcode_config, feature_df, threshold_reco
                     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
+                    threshold_param_new = float(threshold_record.get(ad_abtest_tag)) + update_range * b_i
                 elif b_mean > 0.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
+                    gradient = up_threshold_update.get('gradient')
+                    update_range = up_threshold_update.get('update_range')
+                    b_i = (b_mean - 0.1) // gradient + 1
+                    threshold_param_new = float(threshold_record.get(ad_abtest_tag)) - 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), 'update_param':
-                                             'param_old': round(float(threshold_record.get(ad_abtest_tag)), 4),
-                                             'param_new': round(threshold_param_new, 4)})
+                    robot_msg_record.append({'appType': app_type, 'abtestTag': ad_abtest_tag,
+                                             'gradient': round(gradient, 4), 'range': round(update_range, 4),
+                                             'i': int(b_i),
+                                             'paramOld': round(float(threshold_record.get(ad_abtest_tag)), 4),
+                                             'paramNew': round(threshold_param_new, 4)})
     return threshold_record_new, robot_msg_record