新增子评级
This commit is contained in:
@@ -99,7 +99,7 @@ def calc_consumption_potential(city):
|
|||||||
community_summary_df['avg_cost_score'] = 0
|
community_summary_df['avg_cost_score'] = 0
|
||||||
|
|
||||||
community_summary_df['consumption_potential'] = community_summary_df['total_price_score'] + community_summary_df[
|
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
|
'estate_charge_score'] + community_summary_df['relative_price_ranking_score'] + community_summary_df['avg_cost_score'] + 4099.978248
|
||||||
return community_summary_df
|
return community_summary_df
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ def calc_consumption_rating(community_summary_df):
|
|||||||
"""
|
"""
|
||||||
计算消费等级
|
计算消费等级
|
||||||
"""
|
"""
|
||||||
df = community_summary_df[['_id', 'city', 'consumption_potential']]
|
df = community_summary_df[['_id', 'city', 'consumption_potential', 'total_price_score', 'estate_charge_score', 'relative_price_ranking_score', 'avg_cost_score']]
|
||||||
df = df.dropna(subset=['consumption_potential'])
|
df = df.dropna(subset=['consumption_potential'])
|
||||||
source = "normal_consumption_potential"
|
source = "normal_consumption_potential"
|
||||||
target = "consumption_rating"
|
target = "consumption_rating"
|
||||||
@@ -133,6 +133,11 @@ def calc_consumption_rating(community_summary_df):
|
|||||||
# 极值设置
|
# 极值设置
|
||||||
df = filter_min_max(df)
|
df = filter_min_max(df)
|
||||||
df = gmm_train(total_rate, df, source, target)
|
df = gmm_train(total_rate, df, source, target)
|
||||||
|
# 新增子因子评级
|
||||||
|
df = gmm_train(total_rate, df, "total_price_score", "total_price_rating")
|
||||||
|
df = gmm_train(total_rate, df, "estate_charge_score", "estate_charge_rating")
|
||||||
|
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")
|
||||||
# 批量更新
|
# 批量更新
|
||||||
for index, item in df.iterrows():
|
for index, item in df.iterrows():
|
||||||
row = dict()
|
row = dict()
|
||||||
@@ -140,6 +145,12 @@ def calc_consumption_rating(community_summary_df):
|
|||||||
row['consumption_rating'] = item['consumption_rating']
|
row['consumption_rating'] = item['consumption_rating']
|
||||||
row['consumption_potential'] = item['consumption_potential']
|
row['consumption_potential'] = item['consumption_potential']
|
||||||
row['m_date'] = dateutils.iso_format()
|
row['m_date'] = dateutils.iso_format()
|
||||||
|
row['sub_factor'] = {
|
||||||
|
"total_price_rating": item['total_price_rating'],
|
||||||
|
"estate_charge_rating": item['estate_charge_rating'],
|
||||||
|
"relative_price_rating": item['relative_price_rating'],
|
||||||
|
"avg_cost_rating": item['avg_cost_rating']
|
||||||
|
}
|
||||||
|
|
||||||
action = {'_op_type': 'update', # 操作 index update create delete
|
action = {'_op_type': 'update', # 操作 index update create delete
|
||||||
'_index': index_name, # index
|
'_index': index_name, # index
|
||||||
|
|||||||
Reference in New Issue
Block a user