优化因子不足
This commit is contained in:
@@ -61,16 +61,15 @@ def calc_estate_charge_rating(community_summary_df):
|
||||
"""
|
||||
计算物业费等级
|
||||
"""
|
||||
consumption_aim_df = community_summary_df[['_id', 'city', 'estate_charge']]
|
||||
consumption_aim_df = consumption_aim_df.dropna(subset=['estate_charge'])
|
||||
df = community_summary_df[['_id', 'city', 'estate_charge']]
|
||||
df = df.dropna(subset=['estate_charge'])
|
||||
source = "estate_charge"
|
||||
target = "estate_charge_ranking"
|
||||
actions = list()
|
||||
count = 0
|
||||
|
||||
df = consumption_aim_df.copy()
|
||||
if len(df) < 5:
|
||||
return
|
||||
return []
|
||||
df = gmm_train(5, df, source, target)
|
||||
# 批量更新
|
||||
for index, item in df.iterrows():
|
||||
@@ -95,15 +94,23 @@ def calc_estate_charge_rating(community_summary_df):
|
||||
count += len(actions)
|
||||
actions.clear()
|
||||
log.info("评级完成,共更新: {}".format(count))
|
||||
return df
|
||||
|
||||
|
||||
def sync_by_city(city_now):
|
||||
log.info(f"{city_now}开始评级....")
|
||||
sql = "select id, city, region, name, estate_charge from community_summary where city='" + city_now + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
columns = community_summary_df.columns
|
||||
if 'estate_charge' not in columns:
|
||||
log.warning(f"{city_now}无法评级,缺少因子")
|
||||
return
|
||||
community_summary_df = filter_min_max(city_now, community_summary_df).copy()
|
||||
calc_estate_charge_rating(community_summary_df)
|
||||
save_png(city_now)
|
||||
community_summary_df = calc_estate_charge_rating(community_summary_df)
|
||||
if len(community_summary_df) == 0:
|
||||
log.warning(f"{city_now}无法评级,数量低于5")
|
||||
return
|
||||
save_png(community_summary_df)
|
||||
nextcloudutils.up_to_nextcloud(save_png_path + "/" + city_now + ".png", nextcloud_aim_file_path + "/" + city_now + ".png")
|
||||
|
||||
|
||||
@@ -115,13 +122,10 @@ def sync(city=None):
|
||||
sync_by_city(city)
|
||||
|
||||
|
||||
def save_png(city=None):
|
||||
def save_png(community_city):
|
||||
"""
|
||||
生成财力评级图表
|
||||
"""
|
||||
sql = "select id, city, region, name, estate_charge_ranking, estate_charge from community_summary where city='" + city + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
community_city = filter_min_max(city, community_summary_df).copy()
|
||||
plt.subplot(2, 1, 1)
|
||||
community_city['estate_charge_ranking'].hist(bins=100)
|
||||
plt.xlabel('estate_charge_ranking')
|
||||
@@ -132,7 +136,7 @@ def save_png(city=None):
|
||||
plt.xlabel('estate_charge')
|
||||
plt.tight_layout()
|
||||
|
||||
plt.savefig(save_png_path + "/" + city + ".png")
|
||||
plt.savefig(save_png_path + "/" + community_city['city'].unique()[0] + ".png")
|
||||
# 清图
|
||||
plt.clf()
|
||||
# 清坐标轴
|
||||
|
||||
Reference in New Issue
Block a user