本文整理汇总了Java中org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java LongPrimitiveIterator.next方法的具体用法?Java LongPrimitiveIterator.next怎么用?Java LongPrimitiveIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator
的用法示例。
在下文中一共展示了LongPrimitiveIterator.next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intializeDelegate
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator; //导入方法依赖的package包/类
private void intializeDelegate() {
try {
//iterate over all user ids
LongPrimitiveIterator it = easyrecDataModelDelegate.getUserIDs();
FastByIDMap<PreferenceArray> preferences = new FastByIDMap<PreferenceArray>(easyrecDataModelDelegate.getNumUsers());
FastByIDMap<FastByIDMap<Long>> timestamps = new FastByIDMap<FastByIDMap<Long>>(easyrecDataModelDelegate.getNumUsers());
while (it.hasNext()) {
Long userId = it.next();
//get preferences for each user
PreferenceArray prefs = easyrecDataModelDelegate.getPreferencesFromUser(userId);
preferences.put(userId,prefs);
//get preference times for each user
FastByIDMap<Long> timestampsForUser = new FastByIDMap<Long>(prefs.getIDs().length);
for (Long itemId: prefs.getIDs()) {
timestampsForUser.put(itemId,easyrecDataModelDelegate.getPreferenceTime(userId, itemId));
}
timestamps.put(userId, timestampsForUser);
}
//generate GenericDataModel
setMaxPreference(easyrecDataModelDelegate.getMaxPreference());
setMinPreference(easyrecDataModelDelegate.getMinPreference());
this.inMemoryDelegate = new GenericDataModel(preferences,timestamps);
} catch (TasteException e) {
logger.warn("caught exception while reading preference data", e);
}
}
示例2: partialTransposeTimesSelf
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator; //导入方法依赖的package包/类
/**
* Like {@link MatrixUtils#transposeTimesSelf(FastByIDMap)}, but instead of computing MT * M,
* it computes MT * C * M, where C is a diagonal matrix of 1s and 0s. This is like pretending some
* rows of M are 0.
*
* @see MatrixUtils#transposeTimesSelf(FastByIDMap)
* @see #LOSS_IGNORES_UNSPECIFIED
*/
private static RealMatrix partialTransposeTimesSelf(FastByIDMap<float[]> M,
int dimension,
LongPrimitiveIterator keys) {
RealMatrix result = new Array2DRowRealMatrix(dimension, dimension);
while (keys.hasNext()) {
long key = keys.next();
float[] vector = M.get(key);
for (int row = 0; row < dimension; row++) {
float rowValue = vector[row];
for (int col = 0; col < dimension; col++) {
result.addToEntry(row, col, rowValue * vector[col]);
}
}
}
return result;
}
示例3: testEasyrecDataModel_getItemIDs
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator; //导入方法依赖的package包/类
@Test
public void testEasyrecDataModel_getItemIDs() throws TasteException {
EasyrecDataModel easyrecDataModel = new EasyrecDataModel(TENANT_ID, RATE_ACTION_TYPE_ID, HAS_RATING_VALUES, mahoutDataModelMappingDAO);
LongPrimitiveIterator itemIds = easyrecDataModel.getItemIDs();
String ids = "";
while (itemIds.hasNext()) {
ids += itemIds.next();
}
assertEquals("123", ids);
//Test peek function of the iterator
itemIds = easyrecDataModel.getItemIDs();
ids = "";
ids += itemIds.peek();
while (itemIds.hasNext()) {
ids += itemIds.peek() + "-" + itemIds.next();
if (itemIds.hasNext()) {
ids += "-" + itemIds.peek() + "-" + itemIds.peek() + "#";
} else {
ids += "#";
}
}
assertEquals("11-1-2-2#2-2-3-3#3-3#", ids);
}
示例4: testEasyrecDataModel_getUserIDs
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator; //导入方法依赖的package包/类
@Test
public void testEasyrecDataModel_getUserIDs() throws TasteException {
EasyrecDataModel easyrecDataModel = new EasyrecDataModel(TENANT_ID, RATE_ACTION_TYPE_ID, HAS_RATING_VALUES, mahoutDataModelMappingDAO);
LongPrimitiveIterator userIds = easyrecDataModel.getUserIDs();
String ids = "";
while (userIds.hasNext()) {
ids += userIds.next();
}
assertEquals("12", ids);
}