优化算法
This commit is contained in:
@@ -28,12 +28,12 @@ def worker():
|
|||||||
try:
|
try:
|
||||||
sell_price.calc_sell_price(cmd)
|
sell_price.calc_sell_price(cmd)
|
||||||
end_time = time.clock()
|
end_time = time.clock()
|
||||||
logger.info("Calc :" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time))
|
logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(ex)
|
print(ex)
|
||||||
logger.exception(ex)
|
logger.exception(ex)
|
||||||
end_time = time.clock()
|
end_time = time.clock()
|
||||||
logger.error("Calc :" + str(cmd) + "\t计算失败,耗时:" + (end_time - start_time), ex)
|
logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + (end_time - start_time), ex)
|
||||||
|
|
||||||
|
|
||||||
def format_cmd(cmd):
|
def format_cmd(cmd):
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def timer(func):
|
|||||||
arg_list = list()
|
arg_list = list()
|
||||||
for arg in args:
|
for arg in args:
|
||||||
arg_list.append(str(arg))
|
arg_list.append(str(arg))
|
||||||
performance_logger.info("函数名:(%s) 参数:(%s) 耗时:%f" % (func.__name__, arg_list, end - begin))
|
performance_logger.info("函数名:%-20s\t耗时:%7.4f\t\t参数:(%s)" % (func.__name__, end - begin, arg_list))
|
||||||
return rs
|
return rs
|
||||||
|
|
||||||
return _timer
|
return _timer
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import time
|
|||||||
import fangjia
|
import fangjia
|
||||||
import sklearn.svm
|
import sklearn.svm
|
||||||
import datetime
|
import datetime
|
||||||
|
from fangjia import timer
|
||||||
|
|
||||||
|
|
||||||
# import yesterday
|
# import yesterday
|
||||||
@@ -85,7 +86,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:
|
||||||
@@ -137,7 +138,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]
|
||||||
@@ -306,6 +307,7 @@ def commonprice(ct, rl, p):
|
|||||||
# print('df[kk]',df[kk])
|
# print('df[kk]',df[kk])
|
||||||
return ppp
|
return ppp
|
||||||
|
|
||||||
|
@timer
|
||||||
def neighbor(lng, lat, scale, ct, rl, p):
|
def neighbor(lng, lat, scale, ct, rl, p):
|
||||||
|
|
||||||
###################
|
###################
|
||||||
@@ -414,7 +416,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]
|
||||||
@@ -582,7 +584,7 @@ def commonprice(ct, rl, p):
|
|||||||
return cc1
|
return cc1
|
||||||
else:
|
else:
|
||||||
return cc1
|
return cc1
|
||||||
|
@timer
|
||||||
def consider_villa(ct, rl, p):
|
def consider_villa(ct, rl, p):
|
||||||
|
|
||||||
# print('villa p=',p)
|
# print('villa p=',p)
|
||||||
@@ -637,6 +639,7 @@ 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,
|
||||||
@@ -802,6 +805,7 @@ def commonprice(ct, rl, p):
|
|||||||
|
|
||||||
return lzf, anst
|
return lzf, anst
|
||||||
|
|
||||||
|
@timer
|
||||||
def dglg_out1(junjia, neighb):
|
def dglg_out1(junjia, neighb):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -851,6 +855,7 @@ def commonprice(ct, rl, p):
|
|||||||
location = take_location(ct, rl, p)
|
location = take_location(ct, rl, p)
|
||||||
|
|
||||||
# ttp=time.time()
|
# ttp=time.time()
|
||||||
|
|
||||||
neighb = no_source_price(ct, rl, location, p)
|
neighb = no_source_price(ct, rl, location, p)
|
||||||
|
|
||||||
# print(time.time()-ttp,'m'*20)
|
# print(time.time()-ttp,'m'*20)
|
||||||
@@ -956,7 +961,7 @@ def commonprice(ct, rl, p):
|
|||||||
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:
|
||||||
|
|
||||||
@@ -1071,7 +1076,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)
|
||||||
@@ -1117,13 +1122,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()
|
||||||
@@ -1141,7 +1146,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)
|
||||||
@@ -1328,6 +1333,3 @@ def out_put_price(ct, rl, lk, weekend):
|
|||||||
'problem': mm[0],
|
'problem': mm[0],
|
||||||
}, True
|
}, True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
import zhuge0118A
|
|
||||||
import time
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
|
import sell_price.zhuge0118A as sellPrice
|
||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
ct = '上海'
|
ct = '上海'
|
||||||
@@ -8,6 +9,6 @@ rl = '奉贤'
|
|||||||
lk = '杨王村公寓'
|
lk = '杨王村公寓'
|
||||||
weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")
|
weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")
|
||||||
|
|
||||||
zhuge0118A.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)
|
||||||
|
|||||||
@@ -10,22 +10,39 @@ from collections import Counter
|
|||||||
import numpy
|
import numpy
|
||||||
import collections
|
import collections
|
||||||
import re
|
import re
|
||||||
|
from fangjia import timer
|
||||||
|
# @timer
|
||||||
|
# def url_lable(dmi1):
|
||||||
|
#
|
||||||
|
# company_list=['lianjia','zhuge','5i5j','iwjw','fangdd','centanet', 'cityhouse','esf','baixing','ganji','anjuke','58']
|
||||||
|
# ##有Bug
|
||||||
|
# for p in company_list:
|
||||||
|
# for k in dmi1.index:
|
||||||
|
# ff=dmi1['url'][k]
|
||||||
|
# if type(ff)==str:
|
||||||
|
# if p in dmi1['url'][k]:
|
||||||
|
# dmi1.loc[k,'url']=p
|
||||||
|
# print(dmi1)
|
||||||
|
# return dmi1
|
||||||
|
|
||||||
|
|
||||||
|
def url_to_root(url):
|
||||||
|
company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet', 'cityhouse', 'esf', 'baixing', 'ganji',
|
||||||
|
'anjuke', '58']
|
||||||
|
for c in company_list:
|
||||||
|
if c in url:
|
||||||
|
return c
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
@timer
|
||||||
def url_lable(dmi1):
|
def url_lable(dmi1):
|
||||||
|
|
||||||
company_list=['lianjia','zhuge','5i5j','iwjw','fangdd','centanet',
|
house_list = dmi1.to_dict('records')
|
||||||
'cityhouse','esf','baixing','ganji','anjuke','58']
|
for h in house_list:
|
||||||
|
h["url"] = url_to_root(h["url"])
|
||||||
for p in company_list:
|
dmi1 = pandas.DataFrame(house_list)
|
||||||
#print('p=',p)
|
|
||||||
for k in dmi1.index:
|
|
||||||
#print('k=',k)
|
|
||||||
#print(dmi1['url'][k])
|
|
||||||
ff=dmi1['url'][k]
|
|
||||||
if type(ff)==str:
|
|
||||||
|
|
||||||
if p in dmi1['url'][k]:
|
|
||||||
dmi1.loc[k,'url']=p
|
|
||||||
return dmi1
|
return dmi1
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +63,7 @@ def drop_rubbish(dd1):
|
|||||||
#dd=drop_rubbish(dd1)
|
#dd=drop_rubbish(dd1)
|
||||||
|
|
||||||
|
|
||||||
|
@timer
|
||||||
def zhuge_out(ddd):
|
def zhuge_out(ddd):
|
||||||
|
|
||||||
#print('我在诸葛文件内',ddd)
|
#print('我在诸葛文件内',ddd)
|
||||||
@@ -311,7 +328,7 @@ def zhuge_out(ddd):
|
|||||||
#ddd=url_lable(company_list,ddd)
|
#ddd=url_lable(company_list,ddd)
|
||||||
|
|
||||||
|
|
||||||
|
@timer
|
||||||
def opfm(ddo,fm):
|
def opfm(ddo,fm):
|
||||||
|
|
||||||
floor_column=ddo[fm].dropna()
|
floor_column=ddo[fm].dropna()
|
||||||
@@ -330,7 +347,7 @@ def zhuge_out(ddd):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@timer
|
||||||
def export_pp(ddd):
|
def export_pp(ddd):
|
||||||
|
|
||||||
ddo=ddd
|
ddo=ddd
|
||||||
|
|||||||
Reference in New Issue
Block a user