|
@@ -33,15 +33,15 @@ features = [
|
|
|
'apptype',
|
|
|
'code',
|
|
|
'videoid',
|
|
|
- 'lastonehour_preview', # 过去1小时预曝光人数
|
|
|
- 'lastonehour_view', # 过去1小时曝光人数
|
|
|
- 'lastonehour_play', # 过去1小时播放人数
|
|
|
- 'lastonehour_share', # 过去1小时分享人数
|
|
|
- 'lastonehour_return', # 过去1小时分享,过去1小时回流人数
|
|
|
- 'lastonehour_preview_total', # 过去1小时预曝光次数
|
|
|
- 'lastonehour_view_total', # 过去1小时曝光次数
|
|
|
- 'lastonehour_play_total', # 过去1小时播放次数
|
|
|
- 'lastonehour_share_total', # 过去1小时分享次数
|
|
|
+ 'lastonehour_preview', # 过去1小时预曝光人数 - 区分地域
|
|
|
+ 'lastonehour_view', # 过去1小时曝光人数 - 区分地域
|
|
|
+ 'lastonehour_play', # 过去1小时播放人数 - 区分地域
|
|
|
+ 'lastonehour_share', # 过去1小时分享人数 - 区分地域
|
|
|
+ 'lastonehour_return', # 过去1小时分享,过去1小时回流人数 - 区分地域
|
|
|
+ 'lastonehour_preview_total', # 过去1小时预曝光次数 - 区分地域
|
|
|
+ 'lastonehour_view_total', # 过去1小时曝光次数 - 区分地域
|
|
|
+ 'lastonehour_play_total', # 过去1小时播放次数 - 区分地域
|
|
|
+ 'lastonehour_share_total', # 过去1小时分享次数 - 区分地域
|
|
|
'platform_return',
|
|
|
'lastonehour_show', # 不区分地域
|
|
|
'lastonehour_show_region', # 地域分组
|
|
@@ -162,6 +162,7 @@ def cal_score_initial(df, param):
|
|
|
else:
|
|
|
df['ctr'] = df['lastonehour_play'] / (df['lastonehour_preview'] + 1000)
|
|
|
df['K2'] = df['ctr'].apply(lambda x: 0.6 if x > 0.6 else x)
|
|
|
+
|
|
|
df['platform_return_rate'] = df['platform_return'] / df['lastonehour_return']
|
|
|
|
|
|
df['score1'] = df['share_rate'] * df['back_rate'] * df['log_back'] * df['K2']
|
|
@@ -348,6 +349,36 @@ def cal_score_multiply_return_retention_with_new_return(df, param):
|
|
|
return df
|
|
|
|
|
|
|
|
|
+def cal_score_with_back_view0(df, param):
|
|
|
+ # score = sharerate*backrate*log(return+1)*CTR,
|
|
|
+ # sharerate=(lastonehour_share+1)/(lastonehour_play+1000)
|
|
|
+ # backrate=(lastonehour_return+1)/(lastonehour_share+10)
|
|
|
+ # CTR=(lastonehour_play+1)/(lastonehour_view+100), ctr不进行校正
|
|
|
+ df = df.fillna(0)
|
|
|
+ df['share_rate'] = (df['lastonehour_share'] + 1) / (df['lastonehour_play'] + 1000)
|
|
|
+ df['back_rate'] = (df['lastonehour_return'] + 1) / (df['lastonehour_share'] + 10)
|
|
|
+ df['log_back'] = (df['lastonehour_return'] + 1).apply(math.log)
|
|
|
+ df['ctr'] = (df['lastonehour_play'] + 1) / (df['lastonehour_view'] + 100)
|
|
|
+ df['platform_return_rate'] = df['platform_return'] / df['lastonehour_return']
|
|
|
+ df['score'] = df['share_rate'] * df['back_rate'] * df['log_back'] * df['ctr']
|
|
|
+ df = df.sort_values(by=['score'], ascending=False)
|
|
|
+ return df
|
|
|
+
|
|
|
+
|
|
|
+def cal_score_with_back_view1(df, param):
|
|
|
+ # score = back_play_rate*log(return+1)*CTR,
|
|
|
+ # back_play_rate=(lastonehour_return+1)/(lastonehour_play+1000)
|
|
|
+ # CTR=(lastonehour_play+1)/(lastonehour_view+100), ctr不进行校正
|
|
|
+ df = df.fillna(0)
|
|
|
+ df['back_play_rate'] = (df['lastonehour_return'] + 1) / (df['lastonehour_play'] + 1000)
|
|
|
+ df['log_back'] = (df['lastonehour_return'] + 1).apply(math.log)
|
|
|
+ df['ctr'] = (df['lastonehour_play'] + 1) / (df['lastonehour_view'] + 100)
|
|
|
+ df['platform_return_rate'] = df['platform_return'] / df['lastonehour_return']
|
|
|
+ df['score'] = df['back_play_rate'] * df['log_back'] * df['ctr']
|
|
|
+ df = df.sort_values(by=['score'], ascending=False)
|
|
|
+ return df
|
|
|
+
|
|
|
+
|
|
|
def cal_score(df, param):
|
|
|
if param.get('return_data', None) == 'share_region_return':
|
|
|
if param.get('score_func', None) == 'multiply_return_retention':
|
|
@@ -361,6 +392,10 @@ def cal_score(df, param):
|
|
|
df = cal_score_multiply_return_retention(df=df, param=param)
|
|
|
elif param.get('score_func', None) == 'update_backrate':
|
|
|
df = cal_score_update_backrate(df=df, param=param)
|
|
|
+ elif param.get('score_func', None) == 'back_view0':
|
|
|
+ df = cal_score_with_back_view0(df=df, param=param)
|
|
|
+ elif param.get('score_func', None) == 'back_view1':
|
|
|
+ df = cal_score_with_back_view1(df=df, param=param)
|
|
|
else:
|
|
|
df = cal_score_initial(df=df, param=param)
|
|
|
return df
|