新增消费潜力评级

This commit is contained in:
shenjian@fangjia.com
2022-10-24 15:13:21 +08:00
parent 369ce9668e
commit fb597416e5
11 changed files with 43 additions and 21 deletions
+2 -2
View File
@@ -3,13 +3,13 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
from elasticsearch import helpers
import numpy as np
from concurrent.futures import ThreadPoolExecutor
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -4,11 +4,11 @@
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
from elasticsearch import helpers
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
@@ -25,4 +25,4 @@ if type == 'all':
#total_price.sync()
#traffic.sync()
#medical.sync()
life.sync()
life.sync('上海')
@@ -3,18 +3,40 @@
"""
from goojia_utils import ElasticSearchClient
import pandas as pd
import numpy as np
es206_client = ElasticSearchClient(host='192.168.0.206')
def calcConsumptionPotential():
def calc_consumption_potential(city):
"""
计算消费潜力
"""
sql = "select id, city, region, name, total_price, estate_charge, avg_price_region_ranking, avg_cost from community_summary"
if pd.notna(city):
sql += " where city=" + city
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
community_summary_df['total_price_mean'] = community_summary_df.groupby(by=['city'])['total_price'].transform(np.mean)
community_summary_df['total_price_std'] = community_summary_df.groupby(by=['city'])['total_price'].transform(np.std)
community_summary_df['estate_charge_mean'] = community_summary_df.groupby(by=['city'])['estate_charge'].transform(np.mean)
community_summary_df['estate_charge_std'] = community_summary_df.groupby(by=['city'])['estate_charge'].transform(np.std)
community_summary_df['avg_price_region_ranking_mean'] = community_summary_df.groupby(by=['city'])['avg_price_region_ranking'].transform(np.mean)
community_summary_df['avg_price_region_ranking_std'] = community_summary_df.groupby(by=['city'])['avg_price_region_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['consumption_potential'] = 286.0134196 * (community_summary_df['total_price'] - community_summary_df['total_price_avg']) / community_summary_df['total_price_std'] \
+ 139.1374524 * (community_summary_df['estate_charge'] - community_summary_df['estate_charge_avg']) / community_summary_df['estate_charge_std'] \
+ 21.8427926 * (community_summary_df['avg_price_region_ranking'] - community_summary_df['avg_price_region_ranking_avg']) / community_summary_df['avg_price_region_ranking_std'] \
+ 67.0195871700 * (community_summary_df['avg_cost'] - community_summary_df['avg_cost_mean']) / community_summary_df['avg_cost_std'] + 4099.978248
pass
def calcConsumptionRating():
def calc_consumption_rating():
"""
计算消费等级
"""
+2 -2
View File
@@ -3,13 +3,13 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -3,13 +3,13 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -3,11 +3,11 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from elasticsearch import helpers
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -3,12 +3,12 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
@@ -3,13 +3,13 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
import datetime
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -3,11 +3,11 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
from elasticsearch import helpers
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
+2 -2
View File
@@ -3,13 +3,13 @@
"""
import logging
import pandas as pd
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
log = logging.getLogger(__name__)
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"