How to retrieve original table index in collab filtering (fastai library v1)?

Hey everyone,

CollabDataBunch.from_df re-indexes the items (movies). After calling get_preds on the learner, I’d like to merge the predictions into my original table. However, I can’t find a built-in method to reconstruct the original index to map the predictions to the original table. Is there a way do that?


In the image the index of ‘Casino (1995)’ is 275, while in the original table it’s 693. Is there a built-in method to map from 275 back to 693?

Solved it. For all interested, this can be controlled by the item_name argument in CollabDataBunch.from_df. The example in the lesson sets it to ‘title’. Instead, it can be set to ‘movieId’ which keeps the original index.

1 Like