Java Code Examples for org.apache.mahout.cf.taste.recommender.IDRescorer#isFiltered()
The following examples show how to use
org.apache.mahout.cf.taste.recommender.IDRescorer#isFiltered() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MostPopularItemsIterator.java From myrrix-recommender with Apache License 2.0 | 6 votes |
@Override public RecommendedItem next() { FastByIDFloatMap.MapEntry entry = countsIterator.next(); long id = entry.getKey(); float value = entry.getValue(); IDRescorer theRescorer = rescorer; if (theRescorer != null) { if (theRescorer.isFiltered(id)) { return null; } value = (float) theRescorer.rescore(id, value); if (!LangUtils.isFinite(value)) { return null; } } delegate.set(id, value); return delegate; }
Example 2
Source File: MultiRescorer.java From myrrix-recommender with Apache License 2.0 | 5 votes |
@Override public boolean isFiltered(long itemID) { for (IDRescorer rescorer : rescorers) { if (rescorer.isFiltered(itemID)) { return true; } } return false; }
Example 3
Source File: RecommendIterator.java From myrrix-recommender with Apache License 2.0 | 4 votes |
@Override public RecommendedItem next() { FastByIDMap.MapEntry<float[]> entry = Yiterator.next(); long itemID = entry.getKey(); if (userTagIDs.contains(itemID)) { return null; } FastIDSet theKnownItemIDs = knownItemIDs; if (theKnownItemIDs != null) { synchronized (theKnownItemIDs) { if (theKnownItemIDs.contains(itemID)) { return null; } } } IDRescorer rescorer = this.rescorer; if (rescorer != null && rescorer.isFiltered(itemID)) { return null; } float[] itemFeatures = entry.getValue(); double sum = 0.0; int count = 0; for (float[] oneUserFeatures : features) { sum += SimpleVectorMath.dot(itemFeatures, oneUserFeatures); count++; } if (rescorer != null) { sum = rescorer.rescore(itemID, sum); if (!LangUtils.isFinite(sum)) { return null; } } float result = (float) (sum / count); Preconditions.checkState(LangUtils.isFinite(result), "Bad recommendation value"); delegate.set(itemID, result); return delegate; }