baichongyang 1 年之前
父節點
當前提交
2fcb03ebc2
共有 5 個文件被更改,包括 18 次插入10 次删除
  1. 1 1
      clean.sh
  2. 10 4
      compose_score_3day.py
  3. 2 2
      get3HotRecall.py
  4. 4 2
      run_ctr.sh
  5. 1 1
      test.py

+ 1 - 1
clean.sh

@@ -9,7 +9,7 @@ video_data_path=./data/video_data_${last3day}'*'
 sorted_path=./data/sorted_data_${last3day}'*'
 cls_path=./data/redis_cls_${last3day}'*'
 hour_video_path=./data/hour_video_data_${last3day}'*'
-sorted_hour_path=./data/sorted_hour_data_'*'
+sorted_hour_path=./data/sorted_hour_data_${last3day}'*'
 rec_path=./data/rec_result_'*'
 echo ${merge_path}
 echo ${video_data_path}

+ 10 - 4
compose_score_3day.py

@@ -36,7 +36,7 @@ if __name__=="__main__":
             item_info = data_dict[kid]
             total_info = []
             for i in range(len(item_info)):
-                total_info.append(0.001*float(item_info[i])+float(d_item_info[i]))
+                total_info.append(0.6*float(item_info[i])+0.4*float(d_item_info[i]))
             info_dict[kid] = total_info
         else:
             total_info = []
@@ -63,7 +63,7 @@ if __name__=="__main__":
             item_info = info_dict[kid]
             total_info = []
             for i in range(len(item_info)):
-                total_info.append(0.1*float(item_info[i])+0.3*float(d_item_info[i]))
+                total_info.append(0.7*float(item_info[i])+0.3*float(d_item_info[i]))
             day3_dict[kid] = total_info
         else:
             total_info = []
@@ -73,8 +73,9 @@ if __name__=="__main__":
     print("info3:", len(day3_dict))
     f3 = open("./data/merge_3_days_score_"+nowdate, 'w')
     res_dict = {}
+    res_dict2 = {}
     for k, v in day3_dict.items():
-        score = v[2]+0.1*v[3] 
+        score = v[0]
         new_arr = []
         new_arr.append(score)
         for i in range(4):
@@ -82,10 +83,15 @@ if __name__=="__main__":
         #print(v)
         #print(new_arr)
         total_item_info = json.dumps(new_arr)
-        kid2 = "kp_3:"+k     
+        kid2 = "kp_3:"+k
+        kid3 = "kp_4:"+k
         f3.write(kid2+"\t"+total_item_info+"\n")
         res_dict[kid2] = total_item_info
+        res_dict2[kid3] = total_item_info
     if len(res_dict)>0:
         redis_helper = RedisHelper()
         redis_helper.update_batch_setnx_key(res_dict, 60*60*24*15)
+    if len(res_dict2)>0:
+        redis_helper = RedisHelper()
+        redis_helper.update_batch_setnx_key(res_dict2, 60*60*24*15)
     f2.close()

+ 2 - 2
get3HotRecall.py

@@ -79,9 +79,9 @@ if __name__=="__main__":
     print("sorted_v:", sorted_v[:30])
     recall_name = "hot_3day:"
     hot_recall_res = []
-    for item in sorted_v[:30]:
+    for item in sorted_v[:5]:
         hot_recall_res.append((item[0], item[1][1]))
-    if len(hot_recall_res)>10:
+    if len(hot_recall_res)>5:
         score_info = json.dumps(hot_recall_res)
         print("score_info:", score_info)
         redis_helper.set_data_to_redis(recall_name, score_info, 60*60*24*15)

+ 4 - 2
run_ctr.sh

@@ -2,8 +2,9 @@
 source ~/.bash_profile
 source ~/.bashrc
 
-conda activate python36 
-cd /home/rec/project/git_project/OffLineRec 
+#conda activate python36 
+cd /data/rec_project/OffLineRec
+#cd /home/rec/project/git_project/OffLineRec 
 #cd /data/rec_project/OffLineRec
 #1. download data
 nowday=`date  +"%Y%m%d%H" -d -0days`
@@ -55,6 +56,7 @@ then
     exit 255
 fi
 
+sh clean.sh
 echo "finish sorted"
 
 

+ 1 - 1
test.py

@@ -23,7 +23,7 @@ if __name__=="__main__":
      redis_helper = RedisHelper()
          #redis_helper.update_batch_setnx_key(import_data_dict, 60*60*24*7)
          #con = redis_helper.connect()
-     res = redis_helper.get_data_from_redis("sim_hot_14269966")
+     res = redis_helper.get_data_from_redis("hot_7day:")
      print(res)
      #f2.close()
      #f.close()