Inference for the RBM is pretty straightforward given that we have already generated the file pred_all_recs.csv with all the predictions during training. All we need to do is just extract the test records from the pred_all_recs.csv based on the provided test file. Also, we resort to the original userid and movieid by adding 1 to their current values. The purpose of going back to the original ID is to be able to add the user and movie information from the u.user and u.item files.
The inference block is as follows:
def inference(self):
self.df_result = self.test_df.merge(self.train_df,on=['userid','movieid'])
# in order to get the original ids we just need to add 1
self.df_result['userid'] = self.df_result['userid'] + 1
self.df_result['movieid'] = self.df_result[&apos...