Item recommendation files
Files containing item recommendations contain the recommended items for one user in one line.
An entry line contains the user ID followed by a tab character, followed by the top N recommended items with their score.
0 [9:3.5,7:3.4,3:3.1]means that we recommend the items 9, 7, and 3 to user 0, and that their respective scores are 3.5, 3.4, and 3.1.
The item recommendation tool supports this file format.
--prediction-file=FILE to specify the file name and
--predict-items-number=N to specify the number of items to recommend to each user.
There is currently no class for reading this kind of file in MyMediaLite. Given the information here it should be easy to implement.
Writing item recommendations to a stream or file can be performed using the extension methods defined in
All you need to do is to import the
MyMediaLite.ItemRecommendation namespace via the
Then writing out predictions is simple:
using MyMediaLite.ItemRecommendation; ... recommender.WritePredictions(training_data, candidate_items, predict_items_number, prediction_file);
If you only want predictions for specific users, provide a list of user IDs to the method:
recommender.WritePredictions(training_data, candidate_items, predict_items_number, prediction_file, user_list);
If you mapped the user and item IDs to internal IDs, supply the mapping data as arguments to the method so that the internal IDs can be turned into their original counterparts again:
recommender.WritePredictions(training_data, candidate_items, predict_items_number, prediction_file, user_list, user_mapping, item_mapping);