Creating an Item Based Reviewer with Apache Mahout

I am trying to use Apache Mahout to create an item-based recommendation item, which recommends returning items based on similar items that other users also have.

I'll start by creating the DataModel and then I tried to pass it to various objects ItemSimilarity

:

// Create data model
DataModel datamodel = new FileDataModel(new File("input.csv"));

// ItemSimilarity object
// ItemSimilarity similarity = new EuclideanDistanceSimilarity(datamodel);
// ItemSimilarity similarity = new PearsonCorrelationSimilarity(datamodel);
ItemSimilarity similarity = new CityBlockSimilarity(datamodel);

      

Then I pass the DataModel and ItemSimilarity to the GenericItemBasedRecommender and call the function mostSimilarItems()

and pass it to the list.

ItemBasedRecommender irecommender = new GenericItemBasedRecommender(datamodel, similarity);
List<RecommendedItem> irecommendations = irecommender.mostSimilarItems(item, amount);

      

The class CityBlockSimilarity()

worked fine on a small dataset, but as soon as I switched to a large dataset it became more robust.

Is there another class I need to implement to return recommendations for an item based on other items that are also shared by users?

+3


source to share


1 answer


So it turns out that the class I needed to implement was a class TanimotoCoefficientSimilarity

. As soon as I changed this, I saw the results I wanted to see.

ItemSimilarity similarity = new TanimotoCoefficientSimilarity(datamodel);

      



I was able to leave everything else the same and it works great! Below is a link to the TanimotoCoefficientSimilarity class if you want to read more about it.

+3


source







All Articles