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

Predictions for new users #35

Open
giles7777 opened this issue Oct 18, 2019 · 0 comments
Open

Predictions for new users #35

giles7777 opened this issue Oct 18, 2019 · 0 comments

Comments

@giles7777
Copy link

Thank you for providing detailed code. I have your code running well and can make a topn prediction for any existing users. But, i'm stuck trying to get a prediction set for a new user. I believe it should be possible to do without retraining the whole system? Ie I want a prediction in less then 100ms timeline. I thought with the embeddings it could use those to take a new user with their item ratings and make predictions about their missing ratings. Is that possible with NeuMF or NGCF?

I added this method to batch_test for creating a set of n recommendations for an existing user. But I'm not sure how you'd change that around to handle a new user with their set of item ratings.

def recommend(sess, model, user, num,drop_flag=False):
    user_batch = [user]
    item_batch = range(ITEM_NUM)

    if drop_flag == False:
        rate_batch = sess.run(model.batch_ratings, {model.users: user_batch,
                                                      model.pos_items: item_batch})
    else:
        rate_batch = sess.run(model.batch_ratings, {model.users: user_batch,
                                                      model.pos_items: item_batch,
                                                      model.node_dropout: [0.] * len(eval(args.layer_size)),
                                                      model.mess_dropout: [0.] * len(eval(args.layer_size))})

    rating = rate_batch

    try:
        training_items = data_generator.train_items[user]
    except Exception:
        print("**** Failed to lookup user ***")
        training_items = []

    cols = range(ITEM_NUM)
    df = pd.DataFrame(data=rating,columns=cols,index=[0])
    df.sort_values(by=[0],inplace=True,axis=1,ascending=False)

    icols = list(df)
    cnt = 0

    items = []
    ratings = []
    for i in icols:
        if i in training_items:
            #print("Removing rated: %s at %6.2f" % (data_generator.item_db[i],df[i][0]))
            continue

        items.append(i)
        ratings.append(df[i][0])
        cnt = cnt + 1
        if cnt > num: break

    return items, ratings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant