Commit 044f71fc authored by 郭羽's avatar 郭羽

特征工程优化

parent c0093701
...@@ -834,7 +834,7 @@ if __name__ == '__main__': ...@@ -834,7 +834,7 @@ if __name__ == '__main__':
train_columns = model_columns + ["label", "timestamp"] train_columns = model_columns + ["label", "timestamp"]
trainSamples = samplesWithUserFeatures.select(*train_columns) trainSamples = samplesWithUserFeatures.select(*train_columns)
print("write to hdfs start...") print("write to hdfs start...")
splitTimestamp = int(time.mktime(time.strptime(addDays(-1), "%Y%m%d"))) splitTimestamp = int(time.mktime(time.strptime(addDays(0), "%Y%m%d")))
splitAndSaveTrainingTestSamplesByTimeStamp(trainSamples, splitTimestamp, TRAIN_FILE_PATH) splitAndSaveTrainingTestSamplesByTimeStamp(trainSamples, splitTimestamp, TRAIN_FILE_PATH)
print("write to hdfs success...") print("write to hdfs success...")
timestmp7 = int(round(time.time())) timestmp7 = int(round(time.time()))
......
...@@ -4,6 +4,8 @@ import pandas as pd ...@@ -4,6 +4,8 @@ import pandas as pd
import time import time
import sys import sys
import os import os
from datetime import date, timedelta
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
import utils.connUtils as connUtils import utils.connUtils as connUtils
...@@ -170,12 +172,14 @@ def predict(model_path,df): ...@@ -170,12 +172,14 @@ def predict(model_path,df):
model_new.predict(dd, batch_size=10000) model_new.predict(dd, batch_size=10000)
print("测试样本数:{},测试耗时ms:{}".format(n, int(round(time.time() * 1000)) - timestmp1)) print("测试样本数:{},测试耗时ms:{}".format(n, int(round(time.time() * 1000)) - timestmp1))
def addDays(n, format="%Y%m%d"):
return (date.today() + timedelta(days=n)).strftime(format)
if __name__ == '__main__': if __name__ == '__main__':
curTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) curTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print("train_service执行时间:{}".format(curTime)) print("train_service执行时间:{}".format(curTime))
splitTimestamp = int(time.mktime(time.strptime(addDays(-1), "%Y%m%d")))
# redis中加载数据字典 # redis中加载数据字典
print("redis 中加载模型字典...") print("redis 中加载模型字典...")
......
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