Commit e795d73a authored by 宋柯's avatar 宋柯

模型上线

parent 00a38405
......@@ -51,6 +51,13 @@ def getRedisConn():
# conn = redis.Redis(host="172.18.51.10", port=6379,db=0) #test
return conn
def getRedisConn1():
pool = redis.ConnectionPool(host="172.16.40.133",password="ReDis!GmTx*0aN6",port=6379,db=0)
conn = redis.Redis(connection_pool=pool)
# conn = redis.Redis(host="172.16.50.145", port=6379, password="XfkMCCdWDIU%ls$h",db=0)
# conn = redis.Redis(host="172.18.51.10", port=6379,db=0) #test
return conn
def parseTags(tags,i):
tags_arr = tags.split(",")
if len(tags_arr) >= i:
......@@ -1038,7 +1045,7 @@ def get_and_save_card_feature(itemEsFeatureDF, predictClickStaticFeatures, predi
itemFeature = itemFeature.na.fill(fields_na_value_dict)
itemFeatureDF = itemFeature.toPandas()
conn = getRedisConn()
conn = getRedisConn1()
BATCH = 5000
Key_TMP = 'strategy:model:rank:widedeep:service:feature:tmp'
def concat_service_feature(row):
......@@ -1103,7 +1110,7 @@ def get_and_save_device_feature(spark, fields_na_value_dict, days = 180):
device_feature_df = device_feature_df.na.fill({'os': '-1'})
device_feature_df.printSchema()
device_feature_df = device_feature_df.toPandas()
conn = getRedisConn()
conn = getRedisConn1()
BATCH = 5000
Key_TMP = 'strategy:model:rank:widedeep:device:feature:tmp'
conn.delete(Key_TMP)
......@@ -1180,10 +1187,6 @@ if __name__ == '__main__':
#计算 item 统计特征
clickStaticFeatures, expStaticFeatures = getItemStaticFeatures(itemStatisticStartDays + trainDays + 1, startDay, endDay)
#计算线上推理 item 统计特征
predictClickStaticFeatures, predictExpStaticFeatures = getPredictItemStaticFeatures(itemStatisticStartDays)
#user Profile Feature
userProfileFeatureDF = getUserProfileFeature(spark, addDays(-trainDays - 1, format = "%Y-%m-%d"), addDays(-1, format = "%Y-%m-%d"))
......@@ -1341,7 +1344,10 @@ if __name__ == '__main__':
#存device_id -> USER_CATEGORY_os,
get_and_save_device_feature(spark, fields_na_value_dict)
#存card_id -> ITEM*
#计算线上推理 item 统计特征
predictClickStaticFeatures, predictExpStaticFeatures = getPredictItemStaticFeatures(itemStatisticStartDays)
# 存card_id -> ITEM*
get_and_save_card_feature(itemEsFeatureDF, predictClickStaticFeatures, predictExpStaticFeatures, fields_na_value_dict)
print("总耗时:{} mins".format((time.time() - start)/60))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment