@Test @Ignore public void testFilterAlreadyActedOnPerformance(){ List<RecommendedItemVO<Integer, Integer>> recItems = generateRecommendedItems1ToNNoDuplicates(1000); List<ItemVO<Integer, Integer>> items = generateItems1ToNNoDuplicates(500); Stopwatch sw = new Stopwatch(); sw.start(); for (int i = 0; i < 1000; i++) { RecommenderUtils.filterAlreadyActedOn(recItems,items); } System.out.println("time for 1000 filtering steps: " + sw.stop()); }
public static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems, List<ItemVO<Integer, Integer>> itemsActedOn) { if (recommendedItems == null || recommendedItems.size() == 0 || itemsActedOn == null || itemsActedOn.size() == 0) { return; } Iterator<RecommendedItemVO<Integer, Integer>> recommendedItemsIterator = recommendedItems.iterator(); RecommendedItemVO<Integer, Integer> currentRecommendedItem; Set<ItemVO<Integer, Integer>> items = new HashSet<ItemVO<Integer, Integer>>(itemsActedOn); while (recommendedItemsIterator.hasNext()) { currentRecommendedItem = recommendedItemsIterator.next(); if (items.contains(currentRecommendedItem.getItem())) { recommendedItemsIterator.remove(); } } }
RecommenderUtils { public static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems, List<ItemVO<Integer, Integer>> itemsActedOn) { if (recommendedItems == null || recommendedItems.size() == 0 || itemsActedOn == null || itemsActedOn.size() == 0) { return; } Iterator<RecommendedItemVO<Integer, Integer>> recommendedItemsIterator = recommendedItems.iterator(); RecommendedItemVO<Integer, Integer> currentRecommendedItem; Set<ItemVO<Integer, Integer>> items = new HashSet<ItemVO<Integer, Integer>>(itemsActedOn); while (recommendedItemsIterator.hasNext()) { currentRecommendedItem = recommendedItemsIterator.next(); if (items.contains(currentRecommendedItem.getItem())) { recommendedItemsIterator.remove(); } } } }
RecommenderUtils { public static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems, List<ItemVO<Integer, Integer>> itemsActedOn) { if (recommendedItems == null || recommendedItems.size() == 0 || itemsActedOn == null || itemsActedOn.size() == 0) { return; } Iterator<RecommendedItemVO<Integer, Integer>> recommendedItemsIterator = recommendedItems.iterator(); RecommendedItemVO<Integer, Integer> currentRecommendedItem; Set<ItemVO<Integer, Integer>> items = new HashSet<ItemVO<Integer, Integer>>(itemsActedOn); while (recommendedItemsIterator.hasNext()) { currentRecommendedItem = recommendedItemsIterator.next(); if (items.contains(currentRecommendedItem.getItem())) { recommendedItemsIterator.remove(); } } }  }
RecommenderUtils { public static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems, List<ItemVO<Integer, Integer>> itemsActedOn) { if (recommendedItems == null || recommendedItems.size() == 0 || itemsActedOn == null || itemsActedOn.size() == 0) { return; } Iterator<RecommendedItemVO<Integer, Integer>> recommendedItemsIterator = recommendedItems.iterator(); RecommendedItemVO<Integer, Integer> currentRecommendedItem; Set<ItemVO<Integer, Integer>> items = new HashSet<ItemVO<Integer, Integer>>(itemsActedOn); while (recommendedItemsIterator.hasNext()) { currentRecommendedItem = recommendedItemsIterator.next(); if (items.contains(currentRecommendedItem.getItem())) { recommendedItemsIterator.remove(); } } }  static List<RecommendedItemVO<Integer, Integer>> filterDuplicates(
            List<RecommendedItemVO<Integer, Integer>> recommendedItems, boolean useAveragePredictionValues); static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems,
                                            List<ItemVO<Integer, Integer>> itemsActedOn); }
RecommenderUtils { public static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems, List<ItemVO<Integer, Integer>> itemsActedOn) { if (recommendedItems == null || recommendedItems.size() == 0 || itemsActedOn == null || itemsActedOn.size() == 0) { return; } Iterator<RecommendedItemVO<Integer, Integer>> recommendedItemsIterator = recommendedItems.iterator(); RecommendedItemVO<Integer, Integer> currentRecommendedItem; Set<ItemVO<Integer, Integer>> items = new HashSet<ItemVO<Integer, Integer>>(itemsActedOn); while (recommendedItemsIterator.hasNext()) { currentRecommendedItem = recommendedItemsIterator.next(); if (items.contains(currentRecommendedItem.getItem())) { recommendedItemsIterator.remove(); } } }  static List<RecommendedItemVO<Integer, Integer>> filterDuplicates(
            List<RecommendedItemVO<Integer, Integer>> recommendedItems, boolean useAveragePredictionValues); static void filterAlreadyActedOn(List<RecommendedItemVO<Integer, Integer>> recommendedItems,
                                            List<ItemVO<Integer, Integer>> itemsActedOn);  }