新增子因子评分
This commit is contained in:
@@ -190,19 +190,11 @@ def calc_consumption_rating(community_summary_df):
|
||||
df = gmm_train(total_rate, df, "relative_price_ranking_score", "relative_price_rating")
|
||||
df = gmm_train(total_rate, df, "avg_cost_score", "avg_cost_rating")
|
||||
|
||||
# 计算四分位数和IQR
|
||||
# Q1 = df['consumption_potential'].quantile(0.15)
|
||||
# Q3 = df['consumption_potential'].quantile(0.85)
|
||||
# IQR = Q3 - Q1
|
||||
#
|
||||
# # 定义上下临界点
|
||||
# upper_bound = Q3 + 1.5 * IQR
|
||||
#
|
||||
# # 将超过上临界点的值替换为临界值
|
||||
# df['robust_potential'] = df['consumption_potential'].clip(upper=upper_bound)
|
||||
|
||||
#df = min_max_scale(df, 'robust_potential', 'consumption_score') # 再映射到 [1, 100]
|
||||
# 新增子因子评分
|
||||
df = min_max_scale(df, 'consumption_potential', 'consumption_score')
|
||||
df = min_max_scale(df, 'estate_charge_score', 'estate_charge_score_minmax')
|
||||
df = min_max_scale(df, 'relative_price_ranking_score', 'relative_price_ranking_score_minmax')
|
||||
df = min_max_scale(df, 'avg_cost_score', 'avg_cost_score_minmax')
|
||||
if len(score_df) > 0:
|
||||
# 补充财力评级
|
||||
df = pd.merge(score_df[['_id', 'total_price_rating', 'total_price_score_minmax']], df, how='left', on=['_id'])
|
||||
@@ -235,6 +227,15 @@ def calc_consumption_rating(community_summary_df):
|
||||
if 'avg_cost_rating' in item and pd.notna(item['avg_cost_rating']):
|
||||
row['sub_factor']['avg_cost_rating'] = item['avg_cost_rating']
|
||||
|
||||
if 'total_price_score_minmax' in item and pd.notna(item['total_price_score_minmax']):
|
||||
row['sub_factor']['total_price_score'] = item['total_price_score_minmax']
|
||||
if 'estate_charge_score_minmax' in item and pd.notna(item['estate_charge_score_minmax']):
|
||||
row['sub_factor']['estate_charge_score'] = item['estate_charge_score_minmax']
|
||||
if 'relative_price_ranking_score_minmax' in item and pd.notna(item['relative_price_ranking_score_minmax']):
|
||||
row['sub_factor']['relative_price_score'] = item['relative_price_ranking_score_minmax']
|
||||
if 'avg_cost_score_minmax' in item and pd.notna(item['avg_cost_score_minmax']):
|
||||
row['sub_factor']['avg_cost_score'] = item['avg_cost_score_minmax']
|
||||
|
||||
action = {'_op_type': 'update', # 操作 index update create delete
|
||||
'_index': index_name, # index
|
||||
'_id': _id, # 请勿忘记ID
|
||||
|
||||
Reference in New Issue
Block a user