Getting predictions for one particular observation

In the collaborative filtering lesson, I can see that the predict function gives me the predictions for the validation indexes.

preds = learn.predict()
sns.jointplot(preds, y, kind='hex', stat_func=None);

What can I do to get predictions for one particular user and one particular movie or even for one given row?


I’m also wondering if there’s a way to specify a test set and then call predict with is_test=True. For now to make a prediction on only one observation I do it manually:

def id2idx(uid, mid):
    return cf.user2idx[uid], cf.item2idx[mid]

def predict_rating(uidx, midx):
    res = (m.u(V(uidx)) * m.i(V(midx))).sum(1)
    res = F.sigmoid(res + m.ub(V(uidx)) + m.ib(V(midx))) * (max_rating - min_rating) + min_rating
    return to_np(res.squeeze())

predict_rating(*id2idx(15, 1))

Have either of you found the best way to get predictions for all user/movie combinations while making sure the index/embeddings all are synced up?