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

修改auc计算参数

parent 83b62060
...@@ -3,7 +3,9 @@ import pandas as pd ...@@ -3,7 +3,9 @@ import pandas as pd
from config import * from config import *
if __name__ == "__main__": if __name__ == "__main__":
test = pd.read_csv(DIRECTORY_PATH + "test.csv", header=None) test = pd.read_csv(DIRECTORY_PATH + "test{0}.csv".format(TEST_DATE), header=None)
test_label = test[0].apply(lambda x: x[0]).values test_label = test[0].apply(lambda x: x[0]).values
predict = pd.read_csv(DIRECTORY_PATH + "output.txt", header=None)[0].values predict = pd.read_csv(DIRECTORY_PATH +
"testset{0}_output_model_{1}-{2}_lr{3}_lambda{4}.txt".format(TEST_DATE,
DATA_START_DATE,DATA_END_DATE,"0.03","0.002"), header=None)[0].values
get_roc_curve(test_label, predict, "1") get_roc_curve(test_label, predict, "1")
...@@ -3,28 +3,19 @@ import datetime ...@@ -3,28 +3,19 @@ import datetime
import pickle import pickle
if __name__ == '__main__': if __name__ == '__main__':
data = pd.read_csv("../data/test-data/raw-exposure.csv")[["cid","device_id"]] data = pd.read_csv("../data/test-data/raw-exposure.csv")[["cid", "device_id"]]
data["y"]=1 data["y"] = 1
test_data = data.tail(5) test_data = data.tail(5)
ffm = FFMFormatPandas() ffm = FFMFormatPandas()
data = ffm.fit_transform(data, y='y') data = ffm.fit_transform(data, y='y')
data.to_csv("ffm_data.csv",index=False) data.to_csv("ffm_data.csv", index=False)
with open("ffm.object","wb") as f:
pickle.dump(ffm,f) with open("ffm.object", "wb") as f:
with open("ffm.object","rb") as f: pickle.dump(ffm, f)
with open("ffm.object", "rb") as f:
ffm = pickle.load(f) ffm = pickle.load(f)
result = ffm.transform(test_data) result = ffm.transform(test_data)
print(result) print(result)
data_1 = pd.read_csv("ffm_data.csv",header=None).tail(5) data_1 = pd.read_csv("ffm_data.csv", header=None).tail(5)
print(data_1) print(data_1)
...@@ -3,6 +3,7 @@ from prepareData import fetch_data ...@@ -3,6 +3,7 @@ from prepareData import fetch_data
from utils import FFMFormatPandas from utils import FFMFormatPandas
import pandas as pd import pandas as pd
from config import * from config import *
import pickle
exposure, click, click_device_id = fetch_data( exposure, click, click_device_id = fetch_data(
start_date=DATA_START_DATE, end_date=DATA_END_DATE) start_date=DATA_START_DATE, end_date=DATA_END_DATE)
...@@ -53,6 +54,9 @@ print("Start ffm transform") ...@@ -53,6 +54,9 @@ print("Start ffm transform")
start = time.time() start = time.time()
ffm_train = FFMFormatPandas() ffm_train = FFMFormatPandas()
data = ffm_train.fit_transform(data, y='y') data = ffm_train.fit_transform(data, y='y')
with open(DIRECTORY_PATH+"ffm_{0}_{1}.pkl".format(DATA_START_DATE,DATA_END_DATE), "wb") as f:
pickle.dump(ffm_train, f)
print("done transform ffm") print("done transform ffm")
end = time.time() end = time.time()
print("ffm转化数据耗时:") print("ffm转化数据耗时:")
......
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