How do I create recommendation system to show unread items?

154 views Asked by At

I want to build Recommendation system using Java. Whenever I request for recommendations, it should give n unread items for the user. I tried creating Mahout User based recommendation. However, when program is done executing, it just removes all memory that was already loaded. I want to persist the memory in RAM . How can I persist Java programme data into memory?

I am using same code listed below:

public static void main(String[] args) throws TasteException, IOException {


    DataModel model = new FileDataModel(new File("test.csv"));


    UserSimilarity similarity = new PearsonCorrelationSimilarity(model,Weighting.WEIGHTED);

    UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model);

    Recommender recommender = new GenericUserBasedRecommender(model, neighborhood, similarity);



    List<RecommendedItem> recs = recommender.recommend(2, 20);



    for (RecommendedItem recommendedItem : recs) {

        System.out.println(recommendedItem+".");

    }
1

There are 1 answers

0
mokarakaya On

You should declare recommender object as a static constant. This might give an idea; https://github.com/mkarakaya/timeAwareItemBasedRecommender/blob/master/app/controllers/Application.java