public void verifyOplogs(LongOpenHashSet foundCrfs, LongOpenHashSet foundDrfs, LongOpenHashSet expectedCrfIds, LongOpenHashSet expectedDrfIds) { LongOpenHashSet missingCrfs = calcMissing(foundCrfs, expectedCrfIds); LongOpenHashSet missingDrfs = calcMissing(foundDrfs, expectedDrfIds); // Note that finding extra ones is ok; it is possible we died just // after creating one but before we could record it in the if file // Or died just after deleting it but before we could record it in the if file. boolean failed = false; String msg = null; if (!missingCrfs.isEmpty()) { failed = true; msg = "*.crf files with these ids: " + Arrays.toString(missingCrfs.toArray()); } if (!missingDrfs.isEmpty()) { failed = true; if (msg == null) { msg = ""; } else { msg += ", "; } msg += "*.drf files with these ids: " + Arrays.toString(missingDrfs.toArray()); } if (failed) { msg = "The following required files could not be found: " + msg + "."; throw new IllegalStateException(msg); } }
public void verifyOplogs(LongOpenHashSet foundCrfs, LongOpenHashSet foundDrfs, LongOpenHashSet expectedCrfIds, LongOpenHashSet expectedDrfIds) { LongOpenHashSet missingCrfs = calcMissing(foundCrfs, expectedCrfIds); LongOpenHashSet missingDrfs = calcMissing(foundDrfs, expectedDrfIds); // Note that finding extra ones is ok; it is possible we died just // after creating one but before we could record it in the if file // Or died just after deleting it but before we could record it in the if file. boolean failed = false; String msg = null; if (!missingCrfs.isEmpty()) { failed = true; msg = "*.crf files with these ids: " + Arrays.toString(missingCrfs.toArray()); } if (!missingDrfs.isEmpty()) { failed = true; if (msg == null) { msg = ""; } else { msg += ", "; } msg += "*.drf files with these ids: " + Arrays.toString(missingDrfs.toArray()); } if (failed) { msg = "The following required files could not be found: " + msg + "."; throw new IllegalStateException(msg); } }
@Override public void evaluate(Transaction transaction, LongArrayList recommendations, LongOpenHashSet userTransactions) { //if there is no ground truth, there is nothing to evaluate if (userTransactions == null || userTransactions.isEmpty()) { return; } // if the algorithm does not return any recommendations, count it as 0 if (recommendations.isEmpty()) { results.add(0); return; } // calculate the MRR // if the algorithm retrieves less than k recommendations, we calculate // the real k value for this case int realK = Math.min(k, recommendations.size()); // iterate over relevant items and calculate recall rank for (Long itemID : userTransactions) { for (int i = 0; i < realK; i++) { if (itemID == recommendations.getLong(i)) { results.add(1d/(i+1)); return; } } } //nothing found -> count as zero results.add(0); }
public void evaluate(Transaction transaction, LongArrayList recommendations, LongOpenHashSet userTransactions) { if (userTransactions == null || userTransactions.isEmpty()) { return;