Commit 148393ea authored by 张彦钊's avatar 张彦钊

regroup get_active_users,add some prints

parent 4adad597
...@@ -25,8 +25,8 @@ def feature_en(user_profile): ...@@ -25,8 +25,8 @@ def feature_en(user_profile):
# 虽然预测y,但ffm转化需要y,并不影响预测结果 # 虽然预测y,但ffm转化需要y,并不影响预测结果
data["y"] = 0 data["y"] = 0
data = data.drop("city_id", axis=1) data = data.drop("city_id", axis=1)
print(data.head(2)) print(data.head(1))
print("特征工程处理结束")
return data return data
...@@ -37,7 +37,7 @@ def transform_ffm_format(df, device_id): ...@@ -37,7 +37,7 @@ def transform_ffm_format(df, device_id):
ffm_format_pandas = pickle.load(f) ffm_format_pandas = pickle.load(f)
data = ffm_format_pandas.transform(df) data = ffm_format_pandas.transform(df)
now = datetime.now().strftime("%Y-%m-%d-%H-%M") now = datetime.now().strftime("%Y-%m-%d-%H-%M")
print("ffm格式转化结束")
predict_file_name = DIRECTORY_PATH + "result/{0}_{1}DiaryTop2000.csv".format(device_id, now) predict_file_name = DIRECTORY_PATH + "result/{0}_{1}DiaryTop2000.csv".format(device_id, now)
data.to_csv(predict_file_name, index=False,header=None) data.to_csv(predict_file_name, index=False,header=None)
return predict_file_name return predict_file_name
......
...@@ -27,10 +27,10 @@ def fetch_user_profile(device_id): ...@@ -27,10 +27,10 @@ def fetch_user_profile(device_id):
if user_profile.empty: if user_profile.empty:
print("没有获取到该用户对应的city_id") print("没有获取到该用户对应的city_id")
return {}, user_profile.empty return {}, user_profile.empty
else:
user_profile = user_profile.rename(columns={0:"device_id",1:"city_id"}) user_profile = user_profile.rename(columns={0:"device_id",1:"city_id"})
print("成功获取该用户对应的city_id") print("成功获取该用户对应的city_id")
user_profile_dict = {} user_profile_dict = {}
for i in user_profile.columns: for i in user_profile.columns:
user_profile_dict[i] = user_profile.loc[0, i] user_profile_dict[i] = user_profile.loc[0, i]
return user_profile_dict, user_profile.empty return user_profile_dict, user_profile.empty
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