优化均价算法
This commit is contained in:
@@ -63,7 +63,7 @@ def get_seawater_index_name(city, region):
|
|||||||
return es.get_index_name(city, region)
|
return es.get_index_name(city, region)
|
||||||
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def findHouse(query, fields=None):
|
def findHouse(query, fields=None):
|
||||||
# s = time.time()
|
# s = time.time()
|
||||||
seawater105 = get_collection("fangjia", "seawater", config.get_seawater_host(), 27777)
|
seawater105 = get_collection("fangjia", "seawater", config.get_seawater_host(), 27777)
|
||||||
@@ -76,7 +76,7 @@ def findHouse(query, fields=None):
|
|||||||
# print('flag1')
|
# print('flag1')
|
||||||
lt = 1000
|
lt = 1000
|
||||||
# seawater.find(query,{"p_date":-1}).sort([("p_date",-1)])
|
# seawater.find(query,{"p_date":-1}).sort([("p_date",-1)])
|
||||||
pos = list(seawater105.find(query).limit(lt))
|
pos = list(seawater105.find(query, fields).limit(lt))
|
||||||
data = pandas.DataFrame(pos)
|
data = pandas.DataFrame(pos)
|
||||||
del pos
|
del pos
|
||||||
# print("==================>", time.time() - s)
|
# print("==================>", time.time() - s)
|
||||||
@@ -91,8 +91,8 @@ def findHouse(query, fields=None):
|
|||||||
raise Exception("样本查询失败!")
|
raise Exception("样本查询失败!")
|
||||||
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def find_house_from_elastic_search(city, region, alias, roots=None, pdate=None, cat="sell", limit=100):
|
def find_house_from_elastic_search(city, region, alias, roots=None, pdate=None, cat="sell", limit=1000):
|
||||||
index_name = get_seawater_index_name(city, region)
|
index_name = get_seawater_index_name(city, region)
|
||||||
|
|
||||||
routing_set = [cat + "_" + city + "_" + region + "_" + alia for alia in alias]
|
routing_set = [cat + "_" + city + "_" + region + "_" + alia for alia in alias]
|
||||||
@@ -132,7 +132,7 @@ def find_house_from_elastic_search(city, region, alias, roots=None, pdate=None,
|
|||||||
return pandas.DataFrame([doc["_source"] for doc in response["hits"]["hits"]])
|
return pandas.DataFrame([doc["_source"] for doc in response["hits"]["hits"]])
|
||||||
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def find_sample_pool(query, fields=None):
|
def find_sample_pool(query, fields=None):
|
||||||
# s = time.time()
|
# s = time.time()
|
||||||
seawater105 = get_collection("fangjia", "seawater", config.get_seawater_host(), 27777)
|
seawater105 = get_collection("fangjia", "seawater", config.get_seawater_host(), 27777)
|
||||||
@@ -221,7 +221,7 @@ def dis_feature(query, fields=None):
|
|||||||
|
|
||||||
raise Exception("yang ben cha xun shi bai1")
|
raise Exception("yang ben cha xun shi bai1")
|
||||||
|
|
||||||
@timer
|
|
||||||
def find_seaweed(query, fields=None):
|
def find_seaweed(query, fields=None):
|
||||||
# dirlt=p[0]
|
# dirlt=p[0]
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ dsfjujia_time = front_step_time(430) // 100
|
|||||||
# 存到数据库的日期
|
# 存到数据库的日期
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# date="2018-02-04"
|
# date="2018-02-04"
|
||||||
############################################################
|
############################################################
|
||||||
############################################################
|
############################################################
|
||||||
@@ -65,7 +63,7 @@ value_type = pandas.Series([1, 2, 3, 4, 5, 6, 7],
|
|||||||
|
|
||||||
# 1:指导价 2:自身样本 3:第三方 4:交易数据 5:周边楼盘, 6:推导
|
# 1:指导价 2:自身样本 3:第三方 4:交易数据 5:周边楼盘, 6:推导
|
||||||
|
|
||||||
@timer
|
|
||||||
def commonprice(ct, rl, p):
|
def commonprice(ct, rl, p):
|
||||||
def add_block(ppd):
|
def add_block(ppd):
|
||||||
if 'block' not in ppd.columns:
|
if 'block' not in ppd.columns:
|
||||||
@@ -77,17 +75,18 @@ def commonprice(ct, rl, p):
|
|||||||
ppd['room'] = 2
|
ppd['room'] = 2
|
||||||
return ppd
|
return ppd
|
||||||
|
|
||||||
|
@timer
|
||||||
def some_district_information(ct, rl, lk):
|
def some_district_information(ct, rl, lk):
|
||||||
|
|
||||||
query = {"city": ct, "cat": "sell", "region": rl,
|
query = {"city": ct, "cat": "sell", "region": rl,
|
||||||
"district_name": {"$in": lk},
|
"district_name": {"$in": lk},
|
||||||
"p_date": {"$gt": some_district_information_time}}
|
"p_date": {"$gt": some_district_information_time}}
|
||||||
|
|
||||||
#['total_price', 'area', 'region', 'district_name', 'url', 'block', 'p_date']
|
# ['total_price', 'area', 'region', 'district_name', 'url', 'block', 'p_date']
|
||||||
|
|
||||||
fields1 = {'total_price':1, 'area':1, 'region':1, 'district_name':1, 'url':1, 'p_date':1}
|
fields1 = {'total_price': 1, 'area': 1, 'region': 1, 'district_name': 1, 'url': 1, 'p_date': 1, "name": 1}
|
||||||
|
|
||||||
return fangjia.findHouse(query,fields1)
|
return fangjia.findHouse(query, fields1)
|
||||||
"""
|
"""
|
||||||
return fangjia.find_house_from_elastic_search(ct, rl, lk,
|
return fangjia.find_house_from_elastic_search(ct, rl, lk,
|
||||||
"lianjia.com", some_district_information_time)
|
"lianjia.com", some_district_information_time)
|
||||||
@@ -121,7 +120,7 @@ def commonprice(ct, rl, p):
|
|||||||
return numpy.array([])
|
return numpy.array([])
|
||||||
else:
|
else:
|
||||||
return numpy.array([])
|
return numpy.array([])
|
||||||
@timer
|
|
||||||
def take_location(ct, rl, p):
|
def take_location(ct, rl, p):
|
||||||
|
|
||||||
dirlt = p[0]
|
dirlt = p[0]
|
||||||
@@ -226,6 +225,7 @@ def commonprice(ct, rl, p):
|
|||||||
aa.append(i)
|
aa.append(i)
|
||||||
return set(aa)
|
return set(aa)
|
||||||
|
|
||||||
|
@timer
|
||||||
def new_data(ds):
|
def new_data(ds):
|
||||||
bb = set(ds['name'])
|
bb = set(ds['name'])
|
||||||
bb1 = list(bb)
|
bb1 = list(bb)
|
||||||
@@ -399,7 +399,7 @@ def commonprice(ct, rl, p):
|
|||||||
else:
|
else:
|
||||||
km = vv['price'].dropna()
|
km = vv['price'].dropna()
|
||||||
return int(k_means(km))
|
return int(k_means(km))
|
||||||
@timer
|
|
||||||
def no_source_price(ct, rl, location, p):
|
def no_source_price(ct, rl, location, p):
|
||||||
lk = p[0]
|
lk = p[0]
|
||||||
hg = location.shape[0]
|
hg = location.shape[0]
|
||||||
@@ -567,6 +567,7 @@ def commonprice(ct, rl, p):
|
|||||||
return cc1
|
return cc1
|
||||||
else:
|
else:
|
||||||
return cc1
|
return cc1
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def consider_villa(ct, rl, p):
|
def consider_villa(ct, rl, p):
|
||||||
|
|
||||||
@@ -622,7 +623,6 @@ def commonprice(ct, rl, p):
|
|||||||
|
|
||||||
return villa
|
return villa
|
||||||
|
|
||||||
@timer
|
|
||||||
def dsfjujia(ct, rl, lk):
|
def dsfjujia(ct, rl, lk):
|
||||||
|
|
||||||
query = {"city": ct, "region": rl,
|
query = {"city": ct, "region": rl,
|
||||||
@@ -788,7 +788,6 @@ def commonprice(ct, rl, p):
|
|||||||
|
|
||||||
return lzf, anst
|
return lzf, anst
|
||||||
|
|
||||||
@timer
|
|
||||||
def dglg_out1(junjia, neighb):
|
def dglg_out1(junjia, neighb):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -943,9 +942,9 @@ def commonprice(ct, rl, p):
|
|||||||
elif data.shape[0] > 0:
|
elif data.shape[0] > 0:
|
||||||
|
|
||||||
print('诸葛找房算法')
|
print('诸葛找房算法')
|
||||||
#from zhuge import zhuge_consist
|
# from zhuge import zhuge_consist
|
||||||
data['avg'] = data['total_price'] / data['area']
|
data['avg'] = data['total_price'] / data['area']
|
||||||
@timer
|
|
||||||
def guolv_data11(data, neighb):
|
def guolv_data11(data, neighb):
|
||||||
if type(neighb) is not str:
|
if type(neighb) is not str:
|
||||||
|
|
||||||
@@ -957,57 +956,56 @@ def commonprice(ct, rl, p):
|
|||||||
|
|
||||||
ddd11 = guolv_data11(data, neighb[0])
|
ddd11 = guolv_data11(data, neighb[0])
|
||||||
|
|
||||||
#print('ddd11=',ddd11)
|
# print('ddd11=',ddd11)
|
||||||
|
|
||||||
if ddd11.shape[0] > 2:
|
if ddd11.shape[0] > 2:
|
||||||
|
|
||||||
#s = zhuge_consist.url_lable(ddd11)
|
# s = zhuge_consist.url_lable(ddd11)
|
||||||
#s1 = zhuge_consist.drop_rubbish(s)
|
# s1 = zhuge_consist.drop_rubbish(s)
|
||||||
# print('s1=',s1)
|
# print('s1=',s1)
|
||||||
#s2 = set(s1)
|
# s2 = set(s1)
|
||||||
# print('s2=',s2)
|
# print('s2=',s2)
|
||||||
if ddd11.shape[0] > 3:
|
if ddd11.shape[0] > 3:
|
||||||
|
|
||||||
from zhuge import zhuge_consist
|
from zhuge import zhuge_consist
|
||||||
|
|
||||||
s = zhuge_consist.zhuge_out(ddd11,3,1)
|
s = zhuge_consist.zhuge_out(ddd11, 3, 1)
|
||||||
|
|
||||||
#print('s=',s)
|
# print('s=',s)
|
||||||
|
|
||||||
def compelex(ddd11, s, neighb, junjia):
|
def compelex(ddd11, s, neighb, junjia):
|
||||||
#cc1 = ddd11['avg'].dropna()
|
# cc1 = ddd11['avg'].dropna()
|
||||||
|
|
||||||
#print('cc1=',cc1)
|
# print('cc1=',cc1)
|
||||||
|
|
||||||
kmzhuge = zhuge_consist.zhuge_out(ddd11,3,0)
|
kmzhuge = zhuge_consist.zhuge_out(ddd11, 3, 0)
|
||||||
junjia['zhuge_logic'] = s
|
junjia['zhuge_logic'] = s
|
||||||
|
|
||||||
junjia['kmzg'] = kmzhuge
|
junjia['kmzg'] = kmzhuge
|
||||||
|
|
||||||
if type(neighb) != str and (neighb) != None:
|
if type(neighb) != str and (neighb) != None:
|
||||||
junjia['neighb'] = neighb
|
junjia['neighb'] = neighb
|
||||||
#print('junjia',junjia)
|
# print('junjia',junjia)
|
||||||
|
|
||||||
junjia_front = junjia[['zhuge_logic', 'kmzg']]
|
junjia_front = junjia[['zhuge_logic', 'kmzg']]
|
||||||
|
|
||||||
def drop_ganji(junjia):
|
def drop_ganji(junjia):
|
||||||
a={'ganji_esf_price','anjuke_esf_price'}
|
a = {'ganji_esf_price', 'anjuke_esf_price'}
|
||||||
#print('a=',a)
|
# print('a=',a)
|
||||||
b=set(list(junjia.index))
|
b = set(list(junjia.index))
|
||||||
#print('b=',b)
|
# print('b=',b)
|
||||||
c=a & b
|
c = a & b
|
||||||
|
|
||||||
#print('c=',c)
|
# print('c=',c)
|
||||||
if len(c)==2:
|
if len(c) == 2:
|
||||||
#print('o'*100)
|
# print('o'*100)
|
||||||
return junjia.drop('ganji_esf_price')
|
return junjia.drop('ganji_esf_price')
|
||||||
else:
|
else:
|
||||||
return junjia
|
return junjia
|
||||||
|
|
||||||
|
junjia1 = drop_ganji(junjia)
|
||||||
|
|
||||||
junjia1=drop_ganji(junjia)
|
# print('junjia_ganji=',junjia1,'$'*100)
|
||||||
|
|
||||||
#print('junjia_ganji=',junjia1,'$'*100)
|
|
||||||
cc = group(junjia_front, junjia1, 1)
|
cc = group(junjia_front, junjia1, 1)
|
||||||
# junjia_km=k_means(junjia)
|
# junjia_km=k_means(junjia)
|
||||||
# print('cc=',cc)
|
# print('cc=',cc)
|
||||||
@@ -1084,7 +1082,7 @@ dsf = db136.district_stat
|
|||||||
# client136 = pymongo.MongoClient('192.168.0.136',27017)
|
# client136 = pymongo.MongoClient('192.168.0.136',27017)
|
||||||
# db136 = client136.fangjia
|
# db136 = client136.fangjia
|
||||||
|
|
||||||
@timer
|
|
||||||
def region_district_list(ct, rl):
|
def region_district_list(ct, rl):
|
||||||
# import pandas
|
# import pandas
|
||||||
# client1 = pymongo.MongoClient('192.168.0.136',27017)
|
# client1 = pymongo.MongoClient('192.168.0.136',27017)
|
||||||
@@ -1130,13 +1128,13 @@ def region_list(city):
|
|||||||
data = pandas.DataFrame(pos)
|
data = pandas.DataFrame(pos)
|
||||||
return data['name']
|
return data['name']
|
||||||
|
|
||||||
@timer
|
|
||||||
def add_alias(ppd):
|
def add_alias(ppd):
|
||||||
if 'alias' not in ppd.columns:
|
if 'alias' not in ppd.columns:
|
||||||
ppd['alias'] = '无'
|
ppd['alias'] = '无'
|
||||||
return ppd
|
return ppd
|
||||||
|
|
||||||
@timer
|
|
||||||
def ghhh(kkg):
|
def ghhh(kkg):
|
||||||
kkg = kkg.fillna('无')
|
kkg = kkg.fillna('无')
|
||||||
a = list()
|
a = list()
|
||||||
@@ -1154,7 +1152,7 @@ pt = client1.fangjia_log.calc_command
|
|||||||
|
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
@timer
|
|
||||||
def region_district_list_lk(ct, rl, lk):
|
def region_district_list_lk(ct, rl, lk):
|
||||||
# import pandas
|
# import pandas
|
||||||
# client1 = pymongo.MongoClient('192.168.0.136',27017)
|
# client1 = pymongo.MongoClient('192.168.0.136',27017)
|
||||||
@@ -1257,14 +1255,14 @@ def make_up_price(ct, rl, lk, weekend):
|
|||||||
|
|
||||||
# weekend=weekend00()
|
# weekend=weekend00()
|
||||||
|
|
||||||
@fangjia.timer
|
@timer
|
||||||
def out_put_price(ct, rl, lk, weekend):
|
def out_put_price(ct, rl, lk, weekend):
|
||||||
lf = region_district_list_lk(ct, rl, lk)
|
lf = region_district_list_lk(ct, rl, lk)
|
||||||
lf = add_alias(lf)
|
lf = add_alias(lf)
|
||||||
|
|
||||||
p = ghhh(lf[['name', 'alias', 'estate_type2']])[0]
|
p = ghhh(lf[['name', 'alias', 'estate_type2']])[0]
|
||||||
|
|
||||||
print('p=',p)
|
print('p=', p)
|
||||||
|
|
||||||
mm = commonprice(ct, rl, p)
|
mm = commonprice(ct, rl, p)
|
||||||
|
|
||||||
@@ -1315,7 +1313,7 @@ def out_put_price(ct, rl, lk, weekend):
|
|||||||
|
|
||||||
{"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(102),
|
{"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(102),
|
||||||
'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0),
|
'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0),
|
||||||
'problem': None, "calc_type" : int(0)
|
'problem': None, "calc_type": int(0)
|
||||||
}, True
|
}, True
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1340,6 +1338,6 @@ def out_put_price(ct, rl, lk, weekend):
|
|||||||
|
|
||||||
{"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(3),
|
{"city": ct, "region": rl, "district_name": p[0], "c_date": c_date, 'status': int(3),
|
||||||
'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0),
|
'remark': 'week', 'category': 'sell', "calc_date": weekend, 'priority': int(0),
|
||||||
'problem': mm[0], "calc_type" : int(0)
|
'problem': mm[0], "calc_type": int(0)
|
||||||
}, True
|
}, True
|
||||||
)
|
)
|
||||||
+5
-13
@@ -5,19 +5,11 @@ import sell_price.zhuge0118A as sellPrice
|
|||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
|
|
||||||
#上海嘉定莱茵北郡
|
ct = '上海'
|
||||||
ct='上海'
|
rl = '嘉定'
|
||||||
rl='嘉定'
|
lk = '莱茵北郡'
|
||||||
lk='莱茵北郡'
|
|
||||||
|
|
||||||
#上海闵行上海康城
|
|
||||||
weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")
|
weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")
|
||||||
|
for i in range(0, 100):
|
||||||
sellPrice.out_put_price(ct, rl, lk, weekend)
|
sellPrice.out_put_price(ct, rl, lk, weekend)
|
||||||
|
|
||||||
|
|
||||||
e = time.time()
|
e = time.time()
|
||||||
print(e - s)
|
print(e - s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user