Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASK] How to predict new user score? #2040

Open
rivercat0930 opened this issue Nov 20, 2023 · 0 comments
Open

[ASK] How to predict new user score? #2040

rivercat0930 opened this issue Nov 20, 2023 · 0 comments
Labels
help wanted Need help from developers

Comments

@rivercat0930
Copy link

rivercat0930 commented Nov 20, 2023

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")

Other Comments

@rivercat0930 rivercat0930 added the help wanted Need help from developers label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Need help from developers
Projects
None yet
Development

No branches or pull requests

1 participant