CollabLearner prediction

It’s all detailed in this tutorial: you basically type learn.export() then load your empty learner with learn = load_learner(path) (note that this is on master for now, future v1.0.40).
As for predicting on

  • one item: use learn.predict(a_row_of_ratings) (for instance ratings.iloc[0] but adapt to your test data)
  • a lot of data at the same time: load your learner with a test set, which will allow you to call learn.get_preds(ds_type=DatasetType.Test) with something like:
learn = load_learner(path, test=CollabList.from_df(test_ratings, cat_names=['userId', 'movieId'], path=path))

As for you other question about getting the validation indexes, you can choose the one you want if you use the data block API (just look at the docs then the source code for CollabDataBunch to get an example).

5 Likes