Using exported collaborative filtering learner for predicting

I’ve exported a trained collaborative filtering learner, and am loading it like so:

learn = load_learner('export.pkl')

I’m additionally loading up some data:

df = friend_ratings_df.merge(anime_df).merge(friend_username_to_user_id_df, how='left')
dls = CollabDataLoaders.from_df(df, item_name='title', user_name='username', bs=8192, valid_pct=0.5)

And now I’m trying to use the loaded learner to predict ratings, given this data.

I’ve tried:

  1. Passing both the data frame and the data loaders to learn.get_preds and learn.predict, but none of the combinations have worked
  2. Searching in this forum, but all the questions either never received an answer or were for old versions of the library
  3. Referencing the collaborative filtering tutorial, and Chapter 8 of the book which goes over collaborative filtering, but neither of these resources show how to predict

So, how can I do this? Why isn’t it documented anywhere?

1 Like

Hi @Rabrg I did create a simple add to my notebook for prediction.

Repo

Hope it is of help

1 Like

@fortuala Thank you for linking this! Your extra jupyter cells were very helpful for my understanding of how to get predictions from the model.

Glad to give something back to this amazing community!