Commit cb4429a4 authored by 赵威's avatar 赵威

try predict

parent df27fde1
import datetime import datetime
from models.esmm.fe import (get_device_dict_from_redis, get_diary_dict_from_redis)
from models.esmm.model import model_predict_diary
from utils.cache import redis_client2 from utils.cache import redis_client2
from utils.portrait import user_portrait_tag3_get_candidate_unread_list, user_portrait_tag3_write_ctcvr_data from utils.portrait import (user_portrait_tag3_get_candidate_unread_list, user_portrait_tag3_write_ctcvr_data)
def user_portrait_scan_info(): def user_portrait_scan_info():
...@@ -28,7 +30,11 @@ def user_portrait_scan_info(): ...@@ -28,7 +30,11 @@ def user_portrait_scan_info():
if __name__ == "__main__": if __name__ == "__main__":
device_dict = get_device_dict_from_redis()
diary_dict = get_diary_dict_from_redis()
device_id = "androidid_a25a1129c0b38f7b" device_id = "androidid_a25a1129c0b38f7b"
a = [15420031, 15531030, 16049931, 15335637, 16443431, 16269779, 9389022, 16710435, 16258498, 16435592] model_path = "/home/gmuser/data/models/1595501144"
user_portrait_tag3_write_ctcvr_data(device_id, "diary", a) diary_ids = user_portrait_tag3_get_candidate_unread_list(device_id, "diary")
model_predict_diary(device_id, diary_ids)
# user_portrait_scan_info() # user_portrait_scan_info()
...@@ -118,7 +118,7 @@ def user_portrait_tag3_get_candidate_dict(device_id, content_type, latest=False) ...@@ -118,7 +118,7 @@ def user_portrait_tag3_get_candidate_dict(device_id, content_type, latest=False)
return {} return {}
def user_portrait_tag3_get_candidate_unread_list(device_id, content_type): def user_portrait_tag3_get_candidate_unread_list(device_id, content_type, size=500):
""" """
device_id: device_id:
content_type: diary content_type: diary
...@@ -128,7 +128,7 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type): ...@@ -128,7 +128,7 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type):
read_list, _ = get_user_portrait_tag3_read_v2(device_id, content_type) read_list, _ = get_user_portrait_tag3_read_v2(device_id, content_type)
diary_dict = user_portrait_tag3_get_candidate_dict(device_id, "diary") diary_dict = user_portrait_tag3_get_candidate_dict(device_id, "diary")
if diary_dict: if diary_dict:
lol = remove_read_with_size(diary_dict.values(), "diary", read_list, 500) lol = remove_read_with_size(diary_dict.values(), "diary", read_list, size)
queue = merge_lists(*lol) queue = merge_lists(*lol)
return queue return queue
...@@ -142,7 +142,5 @@ def user_portrait_tag3_write_ctcvr_data(device_id, content_type, data): ...@@ -142,7 +142,5 @@ def user_portrait_tag3_write_ctcvr_data(device_id, content_type, data):
""" """
if data: if data:
key = _user_portrait_tag3_get_ctcvr_candidate_key(device_id, content_type) key = _user_portrait_tag3_get_ctcvr_candidate_key(device_id, content_type)
redis_client4.delete(key)
redis_client4.set(key, json.dumps(data)) redis_client4.set(key, json.dumps(data))
# redis_client4.rpush(key, *data)
redis_client4.expire(key, 60 * 60 * 24 * 30) redis_client4.expire(key, 60 * 60 * 24 * 30)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment