Commit ea80570f authored by 张彦钊's avatar 张彦钊

change preidct and training argument

parent dbcbc226
...@@ -9,8 +9,8 @@ def train(): ...@@ -9,8 +9,8 @@ def train():
ffm_model = xl.create_ffm() ffm_model = xl.create_ffm()
ffm_model.setTrain(DIRECTORY_PATH + "train{0}-{1}.csv".format(DATA_START_DATE, VALIDATION_DATE)) ffm_model.setTrain(DIRECTORY_PATH + "train{0}-{1}.csv".format(DATA_START_DATE, VALIDATION_DATE))
ffm_model.setValidate(DIRECTORY_PATH + "validation{0}.csv".format(VALIDATION_DATE)) ffm_model.setValidate(DIRECTORY_PATH + "validation{0}.csv".format(VALIDATION_DATE))
# log保存路径,如果不加这个参数,日志默认保存在/temp路径下,不符合规范
param = {'task': 'binary', 'lr': lr, 'lambda': l2_lambda, 'metric': 'auc'} param = {'task': 'binary', 'lr': lr, 'lambda': l2_lambda, 'metric': 'auc',"log":"/data2/models/result"}
ffm_model.fit(param, DIRECTORY_PATH + "model_lr{}_lambda{}.out".format(lr, l2_lambda)) ffm_model.fit(param, DIRECTORY_PATH + "model_lr{}_lambda{}.out".format(lr, l2_lambda))
......
...@@ -52,7 +52,9 @@ def predict(user_profile): ...@@ -52,7 +52,9 @@ def predict(user_profile):
ffm_model = xl.create_ffm() ffm_model = xl.create_ffm()
ffm_model.setTest(instance_file_path) ffm_model.setTest(instance_file_path)
ffm_model.setSigmoid() ffm_model.setSigmoid()
ffm_model.predict(DIRECTORY_PATH + "model_lr{}_lambda{}.out".format(lr, l2_lambda), #日志保存路径,如果不加这个参数,日志默认保存在/temp路径下,不符合规范
param = {"log": "/data2/models/result"}
ffm_model.predict(param,DIRECTORY_PATH + "model_lr{}_lambda{}.out".format(lr, l2_lambda),
DIRECTORY_PATH + "result/{0}_output.txt".format(user_profile['device_id'])) DIRECTORY_PATH + "result/{0}_output.txt".format(user_profile['device_id']))
print("预测结束") print("预测结束")
predict_save_to_local(user_profile, instance) predict_save_to_local(user_profile, instance)
......
...@@ -77,7 +77,7 @@ def ffm_transform(data, test_number, validation_number): ...@@ -77,7 +77,7 @@ def ffm_transform(data, test_number, validation_number):
print("Start ffm transform") print("Start ffm transform")
start = time.time() start = time.time()
ffm_train = multiFFMFormatPandas() ffm_train = multiFFMFormatPandas()
data = ffm_train.fit_transform(data, y='y',n=50000,processes=6) data = ffm_train.fit_transform(data, y='y',n=50000,processes=5)
with open(DIRECTORY_PATH+"ffm_{0}_{1}.pkl".format(DATA_START_DATE,DATA_END_DATE), "wb") as f: with open(DIRECTORY_PATH+"ffm_{0}_{1}.pkl".format(DATA_START_DATE,DATA_END_DATE), "wb") as f:
pickle.dump(ffm_train, f) pickle.dump(ffm_train, f)
......
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