From 9e07fdec9a0b1b13660299c8dadff0d1f5b897f8 Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Thu, 9 Mar 2023 12:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E5=8A=9B=E8=AF=84=E7=BA=A7=E4=BA=BA?= =?UTF-8?q?=E5=9D=87=E6=B6=88=E8=B4=B9=E5=99=AA=E9=9F=B3=E8=AF=8D=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/business/business/community/consumption.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dags/business/business/community/consumption.py b/dags/business/business/community/consumption.py index f40b273..c1f159d 100644 --- a/dags/business/business/community/consumption.py +++ b/dags/business/business/community/consumption.py @@ -61,8 +61,11 @@ def calc_consumption_potential(city): community_summary_df['relative_price_ranking_std'] = community_summary_df.groupby(by=['city'])[ 'relative_price_ranking'].transform(np.std) - community_summary_df['avg_cost_mean'] = community_summary_df.groupby(by=['city'])['avg_cost'].transform(np.mean) - community_summary_df['avg_cost_std'] = community_summary_df.groupby(by=['city'])['avg_cost'].transform(np.std) + # 噪音词处理 + community_summary_df['avg_cost_fixed'] = QuantileTransformer(output_distribution="normal").fit_transform(community_summary_df[['avg_cost']]) + + community_summary_df['avg_cost_mean'] = community_summary_df.groupby(by=['city'])['avg_cost_fixed'].transform(np.mean) + community_summary_df['avg_cost_std'] = community_summary_df.groupby(by=['city'])['avg_cost_fixed'].transform(np.std) # 和田等小城市均值可能为0 if community_summary_df['total_price_std'].unique()[0] != 0: @@ -81,7 +84,7 @@ def calc_consumption_potential(city): community_summary_df['relative_price_ranking_score'] = 0 if community_summary_df['avg_cost_std'].unique()[0] != 0: - community_summary_df['avg_cost_score'] = 67.0195871700 * (community_summary_df['avg_cost'] - community_summary_df['avg_cost_mean']) / community_summary_df['avg_cost_std'] + community_summary_df['avg_cost_score'] = 67.0195871700 * (community_summary_df['avg_cost_fixed'] - community_summary_df['avg_cost_mean']) / community_summary_df['avg_cost_std'] else: community_summary_df['avg_cost_score'] = 0