优化和田等小城市方差为0无法评级问题
This commit is contained in:
@@ -70,19 +70,26 @@ def calc_consumption_potential(city):
|
||||
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['total_price_score'] = 286.0134196 * (
|
||||
community_summary_df['total_price'] - community_summary_df['total_price_mean']) / community_summary_df[
|
||||
'total_price_std']
|
||||
# 和田等小城市均值可能为0
|
||||
if community_summary_df['total_price_std'].unique()[0] != 0:
|
||||
community_summary_df['total_price_score'] = 286.0134196 * (community_summary_df['total_price'] - community_summary_df['total_price_mean']) / community_summary_df['total_price_std']
|
||||
else:
|
||||
community_summary_df['total_price_score'] = 0
|
||||
|
||||
community_summary_df['estate_charge_score'] = 139.1374524 * (
|
||||
community_summary_df['estate_charge'] - community_summary_df['estate_charge_mean']) / community_summary_df['estate_charge_std']
|
||||
if community_summary_df['estate_charge_std'].unique()[0] != 0:
|
||||
community_summary_df['estate_charge_score'] = 139.1374524 * (community_summary_df['estate_charge'] - community_summary_df['estate_charge_mean']) / community_summary_df['estate_charge_std']
|
||||
else:
|
||||
community_summary_df['estate_charge_score'] = 0
|
||||
|
||||
community_summary_df['relative_price_ranking_score'] = 21.8427926 * (
|
||||
community_summary_df['relative_price_ranking'] - community_summary_df['relative_price_ranking_mean']) / community_summary_df['relative_price_ranking_std']
|
||||
if community_summary_df['relative_price_ranking_std'].unique()[0] != 0:
|
||||
community_summary_df['relative_price_ranking_score'] = 21.8427926 * (community_summary_df['relative_price_ranking'] - community_summary_df['relative_price_ranking_mean']) / community_summary_df['relative_price_ranking_std']
|
||||
else:
|
||||
community_summary_df['relative_price_ranking_score'] = 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']
|
||||
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']
|
||||
else:
|
||||
community_summary_df['avg_cost_score'] = 0
|
||||
|
||||
community_summary_df['consumption_potential'] = community_summary_df['total_price_score'] + community_summary_df[
|
||||
'estate_charge_score'] + community_summary_df['relative_price_ranking_score'] + community_summary_df['avg_cost_score'] + community_summary_df['avg_cost_score'] + 4099.978248
|
||||
|
||||
Reference in New Issue
Block a user