|
@@ -3,8 +3,11 @@ import time
|
|
|
import datetime
|
|
|
import pandas as pd
|
|
|
from odps import ODPS
|
|
|
-from utils import data_check
|
|
|
+from utils import data_check, RedisHelper
|
|
|
from threading import Timer
|
|
|
+from config import set_config
|
|
|
+config_, _ = set_config()
|
|
|
+redis_helper = RedisHelper()
|
|
|
|
|
|
# ODPS服务配置
|
|
|
odps_config = {
|
|
@@ -89,7 +92,7 @@ def video_data_process(project, table, dt, app_type):
|
|
|
feature_df[column_name] = feature_df[column_name].astype(float)
|
|
|
print(f"feature_df shape: {feature_df.shape}")
|
|
|
print('step 3: add new video feature')
|
|
|
- # 补充新用户默认数据(使用均值)
|
|
|
+ # 补充新视频默认数据(使用均值)
|
|
|
new_video_feature = {
|
|
|
'apptype': app_type,
|
|
|
'videoid': '-1',
|
|
@@ -122,6 +125,29 @@ def video_data_process(project, table, dt, app_type):
|
|
|
if not os.path.exists(predict_data_dir):
|
|
|
os.makedirs(predict_data_dir)
|
|
|
video_df.to_csv(f"{predict_data_dir}/video_feature.csv", index=False)
|
|
|
+ # to redis
|
|
|
+ xgb_config = config_.AD_MODEL_ABTEST_CONFIG['xgb']
|
|
|
+ for ind, row in video_df.iterrows():
|
|
|
+ app_type = row['apptype']
|
|
|
+ video_id = row['videoid']
|
|
|
+ value = {
|
|
|
+ 'video_preview_count_uv_30day': row['video_preview_count_uv_30day'],
|
|
|
+ 'video_preview_count_pv_30day': row['video_preview_count_pv_30day'],
|
|
|
+ 'video_view_count_uv_30day': row['video_view_count_uv_30day'],
|
|
|
+ 'video_view_count_pv_30day': row['video_view_count_pv_30day'],
|
|
|
+ 'video_play_count_uv_30day': row['video_play_count_uv_30day'],
|
|
|
+ 'video_play_count_pv_30day': row['video_play_count_pv_30day'],
|
|
|
+ 'video_share_count_uv_30day': row['video_share_count_uv_30day'],
|
|
|
+ 'video_share_count_pv_30day': row['video_share_count_pv_30day'],
|
|
|
+ 'video_return_count_30day': row['video_return_count_30day'],
|
|
|
+ 'video_ctr_uv_30day': row['video_ctr_uv_30day'],
|
|
|
+ 'video_ctr_pv_30day': row['video_ctr_pv_30day'],
|
|
|
+ 'video_share_rate_uv_30day': row['video_share_rate_uv_30day'],
|
|
|
+ 'video_share_rate_pv_30day': row['video_share_rate_pv_30day'],
|
|
|
+ 'video_return_rate_30day': row['video_return_rate_30day']
|
|
|
+ }
|
|
|
+ key = f"{xgb_config['predict_video_feature_key_prefix']}{app_type}:{video_id}"
|
|
|
+ redis_helper.set_data_to_redis(key_name=key, value=str(value), expire_time=48*3600)
|
|
|
|
|
|
|
|
|
def timer_check():
|