0
$\begingroup$

I was trying to implement Item based Recommender System with the boolean dataset, Dataset example:

      User-id | movie-id | Action | Comedy | Drama
        1              200    0         1        1
        2              210    1         1        0

And I tried implementing it with item-based similarity algorithm as follows:

package prediction.contentrecommender;

import java.io.File; import java.io.IOException; import java.util.List;

import org.apache.mahout.cf.taste.common.TasteException; import org.apache.mahout.cf.taste.impl.model.file.FileDataModel; import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender; import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity; import org.apache.mahout.cf.taste.model.DataModel; import org.apache.mahout.cf.taste.recommender.RecommendedItem; import org.apache.mahout.cf.taste.similarity.ItemSimilarity; import org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefItemBasedRecommender;

public class ContentRecommender {

/**
 * @param args
 */
public static void main(String[] args) {
    int userid=10;
       int noOfRecommendations=1;


    try {

        DataModel dm = new FileDataModel(new File("data/dataset.csv"));
        ItemSimilarity sim = new TanimotoCoefficientSimilarity(dm);
        GenericItemBasedRecommender recommender =
            new GenericBooleanPrefItemBasedRecommender(dm,sim);

     List<RecommendedItem> recommendations =
         recommender.recommend(userid, noOfRecommendations);
            for(RecommendedItem recommendation : recommendations)
             {
                System.out.println(recommendation.getItemID());
            }


    } 
    catch (IOException e) 
    {
        System.out.println("there is an error");
        e.printStackTrace();
    } 
   catch (TasteException e) 
    {
        System.out.println("error");
        e.printStackTrace();
    }


}

}

When I am running this code, I am not getting any output, although there is no error.I don't know what can be the problem. Can anyone figure out how to implement item-based similarity algorithm with Boolean data-set.

$\endgroup$
1
  • $\begingroup$ Debugging your code might not be a good fit here, as it is unlikely to be of interest to anyone other than you. $\endgroup$ – D.W. Mar 8 '17 at 21:32
1
$\begingroup$

The code and data combination is too small for predicting a solution. But note that you will not get any answer if there are no recommendations made. In this case there will be no exception either. Looks like your code

List<RecommendedItem> recommendations =
     recommender.recommend(userid, noOfRecommendations);

returned no recommendations. You should try with a variety of data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.