优化物业费评级
This commit is contained in:
@@ -7,6 +7,7 @@ import logging
|
||||
import os
|
||||
from elasticsearch import helpers
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
from sklearn.mixture import GaussianMixture
|
||||
|
||||
@@ -47,13 +48,17 @@ def filter_min_max(city, community_summary_df):
|
||||
"""
|
||||
过滤极值
|
||||
"""
|
||||
if city in factor_dict:
|
||||
community_summary_df.loc[
|
||||
community_summary_df['estate_charge'] < factor_dict[city]['min_estate_charge'], 'estate_charge'] = \
|
||||
factor_dict[city]['min_estate_charge']
|
||||
community_summary_df.loc[
|
||||
community_summary_df['estate_charge'] > factor_dict[city]['max_estate_charge'], 'estate_charge'] = \
|
||||
factor_dict[city]['max_estate_charge']
|
||||
estate_charge5 = np.percentile(a=community_summary_df['estate_charge'], q=2, axis=0)
|
||||
estate_charge95 = np.percentile(a=community_summary_df['estate_charge'], q=98, axis=0)
|
||||
community_summary_df.loc[community_summary_df['estate_charge'] > estate_charge95, 'estate_charge'] = estate_charge95
|
||||
community_summary_df.loc[community_summary_df['estate_charge'] < estate_charge5, 'estate_charge'] = estate_charge5
|
||||
# if city in factor_dict:
|
||||
# community_summary_df.loc[
|
||||
# community_summary_df['estate_charge'] < factor_dict[city]['min_estate_charge'], 'estate_charge'] = \
|
||||
# factor_dict[city]['min_estate_charge']
|
||||
# community_summary_df.loc[
|
||||
# community_summary_df['estate_charge'] > factor_dict[city]['max_estate_charge'], 'estate_charge'] = \
|
||||
# factor_dict[city]['max_estate_charge']
|
||||
return community_summary_df
|
||||
|
||||
|
||||
@@ -105,6 +110,7 @@ def sync_by_city(city_now):
|
||||
if 'estate_charge' not in columns:
|
||||
log.warning(f"{city_now}无法评级,缺少因子")
|
||||
return
|
||||
community_summary_df = community_summary_df.dropna(how='any').copy()
|
||||
community_summary_df = filter_min_max(city_now, community_summary_df).copy()
|
||||
community_summary_df = calc_estate_charge_rating(community_summary_df)
|
||||
if len(community_summary_df) == 0:
|
||||
|
||||
Reference in New Issue
Block a user