List of usage examples for org.apache.mahout.cf.taste.impl.recommender GenericItemBasedRecommender mostSimilarItems
@Override public List<RecommendedItem> mostSimilarItems(long[] itemIDs, int howMany) throws TasteException
From source file:businessreco.BusinessReco.java
public static void main(String args[]) { try {/*from ww w. j av a2s.c o m*/ //Loading the DATA; DataModel dm = new FileDataModel(new File( "C:\\Users\\bryce\\Course Work\\3. Full Summer\\Big Data\\Final Project\\Yelp\\FINAL CODE\\Mahout\\data\\busirec_new.csv")); // We use the below line to relate businesses. //ItemSimilarity sim = new LogLikelihoodSimilarity(dm); TanimotoCoefficientSimilarity sim = new TanimotoCoefficientSimilarity((dm)); //Using the below line get recommendations GenericItemBasedRecommender recommender = new GenericItemBasedRecommender(dm, sim); //Looping through every business. for (LongPrimitiveIterator items = dm.getItemIDs(); items.hasNext();) { long itemId = items.nextLong(); // For each business we recommend 3 businesses. List<RecommendedItem> recommendations = recommender.mostSimilarItems(itemId, 2); for (RecommendedItem recommendation : recommendations) { System.out.println(itemId + "," + recommendation.getItemID() + "," + recommendation.getValue()); } } } catch (IOException | TasteException e) { System.out.println(e); } }