Java Code Examples for it.unimi.dsi.fastutil.ints.IntList#subList()
The following examples show how to use
it.unimi.dsi.fastutil.ints.IntList#subList() .
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: NoveltyEvaluator.java From jstarcraft-ai with Apache License 2.0 | 6 votes |
/** * Evaluate on the test set with the the list of recommended items. * * @param testMatrix the given test set * @param recommendedList the list of recommended items * @return evaluate result */ @Override protected float measure(IntSet checkCollection, IntList rankList) { if (rankList.size() > size) { rankList = rankList.subList(0, size); } float sum = 0F; for (int rank : rankList) { int count = itemCounts[rank]; if (count > 0) { float probability = ((float) count) / numberOfUsers; float entropy = (float) -Math.log(probability); sum += entropy; } } return (float) (sum / Math.log(2F)); }
Example 2
Source File: MAPEvaluator.java From jstarcraft-ai with Apache License 2.0 | 6 votes |
@Override protected float measure(IntSet checkCollection, IntList rankList) { if (rankList.size() > size) { rankList = rankList.subList(0, size); } int count = 0; float map = 0F; for (int index = 0; index < rankList.size(); index++) { int itemIndex = rankList.get(index); if (checkCollection.contains(itemIndex)) { count++; map += 1F * count / (index + 1); } } return map / (checkCollection.size() < rankList.size() ? checkCollection.size() : rankList.size()); }
Example 3
Source File: PrecisionEvaluator.java From jstarcraft-ai with Apache License 2.0 | 5 votes |
@Override protected float measure(IntSet checkCollection, IntList rankList) { if (rankList.size() > size) { rankList = rankList.subList(0, size); } int count = 0; for (int itemIndex : rankList) { if (checkCollection.contains(itemIndex)) { count++; } } return count / (size + 0F); }
Example 4
Source File: RecallEvaluator.java From jstarcraft-ai with Apache License 2.0 | 5 votes |
@Override protected float measure(IntSet checkCollection, IntList rankList) { if (rankList.size() > size) { rankList = rankList.subList(0, size); } int count = 0; for (int itemIndex : rankList) { if (checkCollection.contains(itemIndex)) { count++; } } return count / (checkCollection.size() + 0F); }