mahout技术⽂档
//⾸先获得⽤户本⼈⾃⼰借过的所有书
PreferenceArray preferencesFromUr = getDataModel().getPreferencesFromUr(urID);
//以下获得读者借过的书,其他也借过那些书的,取那些读者借阅过的所有书,作为候选物品
FastIDSet possibleItemsIDs = new FastIDSet();
for (long itemID : preferredItemIDs) {
PreferenceArray itemPreferences = PreferencesForItem(itemID);
廖英子
int numUrsPreferringItem = itemPreferences.length();
for (int index = 0; index < numUrsPreferringItem; index++) {
possibleItemsIDs.UrID(index)));
}
}
鼻梁有节>观赏鱼什么鱼最好养
芥菜丝腌制方法//将所有的候选物品,与读者借阅过的每⼀本书,做相似度计算
如何调理脾胃
double[] similarities = getSimilarity().itemSimilarities(itemID, IDs());代表英语
boolean foundAPref = fal;
double totalSimilarity = 0.0;
for (double theSimilarity : similarities) {
if (!Double.isNaN(theSimilarity)) {
foundAPref = true;
totalSimilarity += theSimilarity;
}
形成近义词
}
岁月如歌小说return foundAPref ? (float) totalSimilarity : Float.NaN;
//之后取相似度最⾼的10本书,返回
List<RecommendedItem> topItems = TopItems(howMany, possibleItemIDs.iterator(), rescorer, estimator);