|
@@ -9,8 +9,6 @@ log_ = Log()
|
|
|
|
|
|
config_ = set_config()
|
|
|
def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
- recall_list = []
|
|
|
- vidKeys = []
|
|
|
feature_dict = {}
|
|
|
# defult value
|
|
|
apptype = 4
|
|
@@ -21,6 +19,8 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
machineinfo_platform = 'android'
|
|
|
sencetype = 100078
|
|
|
machineinfo_model ='M2006C3LC'
|
|
|
+ city_code = -1
|
|
|
+ province_code = -1
|
|
|
if env_dict and len(env_dict)>0:
|
|
|
apptype = env_dict.get('app_type',4)
|
|
|
pagesource = env_dict.get('pagesource', '')
|
|
@@ -30,10 +30,8 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
recommendsource = env_dict.get('recommendsource', '0')
|
|
|
machineinfo_platform = env_dict.get('machineinfo_platform', '')
|
|
|
sencetype = env_dict.get('sencetype', '')
|
|
|
- redisObj = RedisHelper()
|
|
|
- pre_str = "v_ctr:"
|
|
|
- hour_pre_str = "v_hour_ctr:"
|
|
|
- hour_vidKeys = []
|
|
|
+ city_code = env_dict.get('city_code', -1)
|
|
|
+ province_code = env_dict.get('province_code', -1)
|
|
|
mid_list = []
|
|
|
videoid_list = []
|
|
|
apptype_list = []
|
|
@@ -41,7 +39,6 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
versioncode_list = []
|
|
|
machineinfo_brand_list = []
|
|
|
machineinfo_model_list = []
|
|
|
- recommendsource_list = []
|
|
|
machineinfo_platform_list = []
|
|
|
sencetype_list = []
|
|
|
day_rov_list = []
|
|
@@ -56,33 +53,31 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
day_view_pv_list = []
|
|
|
day_view_users_list = []
|
|
|
day_share_users = []
|
|
|
- for recall_item in data['rov_pool_recall']:
|
|
|
- if len(recall_item)<=0:
|
|
|
- continue
|
|
|
- vid = recall_item.get("videoId",0)
|
|
|
- mid_list.append(mid)
|
|
|
- videoid_list.append(int(vid))
|
|
|
- apptype_list.append(apptype)
|
|
|
- pagesource_list.append(pagesource)
|
|
|
- versioncode_list.append(versioncode)
|
|
|
- machineinfo_brand_list.append(machineinfo_brand)
|
|
|
- machineinfo_model_list.append(machineinfo_model)
|
|
|
- recommendsource_list.append(recommendsource)
|
|
|
- machineinfo_platform_list.append(machineinfo_platform)
|
|
|
- sencetype_list.append(sencetype)
|
|
|
- vidKeys.append(pre_str + str(vid))
|
|
|
- hour_vidKeys.append(hour_pre_str+str(vid))
|
|
|
- recall_list.append(recall_item)
|
|
|
- #print("vidKeys:", vidKeys)
|
|
|
- video_static_info = redisObj.get_batch_key(vidKeys)
|
|
|
- video_hour_static_info = redisObj.get_batch_key(hour_vidKeys)
|
|
|
+ recommendsource_list = []
|
|
|
+ recall_list = env_dict.get('recall_list', [])
|
|
|
+ city_list = []
|
|
|
+ province_list = []
|
|
|
+ if recall_list and len(recall_list)>0:
|
|
|
+ for i in range(len(recall_list)):
|
|
|
+ mid_list.append(mid)
|
|
|
+ videoid_list.append(int(recall_list[i]))
|
|
|
+ apptype_list.append(apptype)
|
|
|
+ pagesource_list.append(pagesource)
|
|
|
+ versioncode_list.append(versioncode)
|
|
|
+ machineinfo_brand_list.append(machineinfo_brand)
|
|
|
+ machineinfo_model_list.append(machineinfo_model)
|
|
|
+ recommendsource_list.append(recommendsource)
|
|
|
+ machineinfo_platform_list.append(machineinfo_platform)
|
|
|
+ sencetype_list.append(sencetype)
|
|
|
+ city_list.append(int(city_code))
|
|
|
+ province_list.append(int(province_code))
|
|
|
+ video_static_info = env_dict.get('vid_day_fea_list', [])
|
|
|
+ video_hour_static_info = env_dict.get('vid_hour_fea_list', [])
|
|
|
#print("video_static_info:",video_static_info)
|
|
|
- if video_static_info:
|
|
|
+ if video_static_info and len(video_static_info)>0:
|
|
|
for i in range(len(video_static_info)):
|
|
|
try:
|
|
|
- # print(video_scores[i])
|
|
|
- vid = vidKeys[i].replace(pre_str,"")
|
|
|
- if video_static_info[i] :
|
|
|
+ if video_static_info[i] and len(video_static_info[i])>0:
|
|
|
per_video_staic = json.loads(video_static_info[i])
|
|
|
day_rov_list.append(float(per_video_staic[0]))
|
|
|
day_share_return_score_list.append(float(per_video_staic[1]))
|
|
@@ -118,12 +113,10 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
hour_return_rate_list = []
|
|
|
hour_ctr_score_list = []
|
|
|
|
|
|
- if video_hour_static_info:
|
|
|
+ if video_hour_static_info and len(video_hour_static_info)>0:
|
|
|
for i in range(len(video_hour_static_info)):
|
|
|
try:
|
|
|
- # print(video_scores[i])
|
|
|
- vid = hour_vidKeys[i].replace(hour_pre_str,"")
|
|
|
- if video_hour_static_info[i] :
|
|
|
+ if video_hour_static_info[i] and len(video_hour_static_info[i])>0:
|
|
|
per_hour_video_staic = json.loads(video_hour_static_info[i])
|
|
|
hour_rov_list.append(float(per_hour_video_staic[0]))
|
|
|
hour_share_return_score_list.append(float(per_hour_video_staic[1]))
|
|
@@ -177,7 +170,9 @@ def get_featurs(mid, data, size, top_K, flow_pool_P, env_dict=None):
|
|
|
feature_dict["hour_share_score_list"] = hour_share_score_list
|
|
|
feature_dict["hour_return_rate_list"] = hour_return_rate_list
|
|
|
feature_dict["hour_ctr_score_list"] = hour_ctr_score_list
|
|
|
- return feature_dict, recall_list
|
|
|
+ feature_dict["city_code"] = city_list
|
|
|
+ feature_dict["province_code"] = province_list
|
|
|
+ return feature_dict
|
|
|
|
|
|
|
|
|
def insert_static_default_fea(day_ctr_score_list, day_play_pv_list, day_play_users_list, day_return_rate_list,
|
|
@@ -224,9 +219,11 @@ def get_tf_serving_sores(feature_dict):
|
|
|
# "day_view_users":feature_dict["day_view_users_list"],
|
|
|
"hour_rov": feature_dict["hour_rov_list"],
|
|
|
"hour_share_score": feature_dict["hour_share_score_list"],
|
|
|
- "hour_share_return_score": feature_dict["hour_share_return_score_list"],
|
|
|
- "hour_return_rate": feature_dict["hour_return_rate_list"],
|
|
|
- "hour_ctr_score": feature_dict["hour_ctr_score_list"]
|
|
|
+ #"hour_share_return_score": feature_dict["hour_share_return_score_list"],
|
|
|
+ #"hour_return_rate": feature_dict["hour_return_rate_list"],
|
|
|
+ #"hour_ctr_score": feature_dict["hour_ctr_score_list"],
|
|
|
+ "city_code": feature_dict['city_code'],
|
|
|
+ "province_code": feature_dict['province_code']
|
|
|
}
|
|
|
request_data_dict= {}
|
|
|
request_data_dict["inputs"] = inputs_data
|