help wanted
仓库指标
- Star
- (17,706 star)
- PR 合并指标
- (平均合并 6天 16小时) (30 天内合并 10 个 PR)
描述
Description
I already save the NeuMF model, then I want to use it, it can be load, but when I add new user in test.csv, it will get Exception has occurred: KeyError, 101.0, this 101.0 is the 101 user as the same I was add in test.csv Does this method is wrong to predict new user? and How to do it? Thank you everyone
code:
data = NCFDataset(
train_file=train_file,
test_file=leave_one_out_test_file,
seed=SEED,
overwrite_test_file_full=True,
col_user="user_id",
col_item="location_id",
col_rating="score"
)
model = NCF(
n_users=data.n_users,
n_items=data.n_items,
model_type="NeuMF",
n_factors=3,
layer_sizes=[64,32,16,8,4],
n_epochs=50,
batch_size=1024,
learning_rate=0.001,
verbose=10,
seed=SEED
)
model.load(neumf_dir="./NeuMFmodel")
model.user2id=data.user2id
model.item2is=data.item2id
model.id2user=data.id2user
model.id2item=data.id2item
predictions = [[row.user_id, row.location_id, model.predict(row.user_id, row.location_id)]
for(_, row) in test.iterrows()]
predictions = pd.DataFrame(predictions, columns=['user_id', 'location_id', 'prediction'])
predictions.to_csv("./prediction.csv")