org.mymedialite.itemrec
Class Extensions

java.lang.Object
  extended by org.mymedialite.itemrec.Extensions

public class Extensions
extends java.lang.Object

Class that contains static methods for item prediction.


Method Summary
static java.util.List<java.lang.Integer> predictItems(IRecommender recommender, int user_id, java.util.Collection<java.lang.Integer> candidate_items)
          Predict items for a given user.
static java.util.List<java.lang.Integer> predictItems(IRecommender recommender, int user_id, int max_item_id)
          predict items for a specific users.
static void writePredictions(IRecommender recommender, int user_id, java.util.Collection<java.lang.Integer> candidate_items, java.util.Collection<java.lang.Integer> ignore_items, int num_predictions, java.io.PrintWriter writer, IEntityMapping user_mapping, IEntityMapping item_mapping)
          Write item predictions (scores) to a TextWriter object.
static void writePredictions(IRecommender recommender, IPosOnlyFeedback train, java.util.Collection<java.lang.Integer> candidate_items, int num_predictions, java.io.PrintWriter writer, java.util.List<java.lang.Integer> users, IEntityMapping user_mapping, IEntityMapping item_mapping)
          Write item predictions (scores) to a TextWriter object.
static void writePredictions(IRecommender recommender, IPosOnlyFeedback train, java.util.Collection<java.lang.Integer> candidate_items, int num_predictions, java.lang.String filename, java.util.List<java.lang.Integer> users, IEntityMapping user_mapping, IEntityMapping item_mapping)
          Write item predictions (scores) to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writePredictions

public static void writePredictions(IRecommender recommender,
                                    IPosOnlyFeedback train,
                                    java.util.Collection<java.lang.Integer> candidate_items,
                                    int num_predictions,
                                    java.lang.String filename,
                                    java.util.List<java.lang.Integer> users,
                                    IEntityMapping user_mapping,
                                    IEntityMapping item_mapping)
                             throws java.io.IOException
Write item predictions (scores) to a file.

Parameters:
recommender - the IRecommender to use for making the predictions
train - a user-wise IPosOnlyFeedback containing the items already observed
candidate_items - the list of candidate items
num_predictions - the number of items to return per user, -1 if there should be no limit
filename - the name of the file to write to
users - a list of users to make recommendations for
user_mapping - an IEntityMapping object for the user IDs
item_mapping - an IEntityMapping object for the item IDs
Throws:
java.io.IOException

writePredictions

public static void writePredictions(IRecommender recommender,
                                    IPosOnlyFeedback train,
                                    java.util.Collection<java.lang.Integer> candidate_items,
                                    int num_predictions,
                                    java.io.PrintWriter writer,
                                    java.util.List<java.lang.Integer> users,
                                    IEntityMapping user_mapping,
                                    IEntityMapping item_mapping)
Write item predictions (scores) to a TextWriter object.

Parameters:
recommender - the IRecommender to use for making the predictions
train - a user-wise IPosOnlyFeedback containing the items already observed
candidate_items - the list of candidate items
num_predictions - the number of items to return per user, -1 if there should be no limit
writer - the TextWriter to write to
users - a list of users to make recommendations for; if null, all users in train will be provided with recommendations
user_mapping - an IEntityMapping object for the user IDs
item_mapping - an IEntityMapping object for the item IDs

writePredictions

public static void writePredictions(IRecommender recommender,
                                    int user_id,
                                    java.util.Collection<java.lang.Integer> candidate_items,
                                    java.util.Collection<java.lang.Integer> ignore_items,
                                    int num_predictions,
                                    java.io.PrintWriter writer,
                                    IEntityMapping user_mapping,
                                    IEntityMapping item_mapping)
Write item predictions (scores) to a TextWriter object.

Parameters:
recommender - the to use for making the predictions
user_id - the ID of the user to make recommendations for
candidate_items - the list of candidate items
ignore_items - a list of items for which no predictions should be made
num_predictions - the number of items to return per user, -1 if there should be no limit
writer - the to write to
user_mapping - an object for the user IDs
item_mapping - an object for the item IDs

predictItems

public static java.util.List<java.lang.Integer> predictItems(IRecommender recommender,
                                                             int user_id,
                                                             int max_item_id)
predict items for a specific users.

Parameters:
recommender - the object to use for the predictions
user_id - the user ID
max_item_id - the maximum item ID
Returns:
a list sorted list of item IDs

predictItems

public static java.util.List<java.lang.Integer> predictItems(IRecommender recommender,
                                                             int user_id,
                                                             java.util.Collection<java.lang.Integer> candidate_items)
Predict items for a given user.

Parameters:
recommender - the recommender to use
user_id - the numerical ID of the user
candidate_items - a collection of numerical IDs of candidate items
Returns:
an ordered list of items, the most likely item first