• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LongSortedSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongSortedSet的典型用法代码示例。如果您正苦于以下问题:Java LongSortedSet类的具体用法?Java LongSortedSet怎么用?Java LongSortedSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LongSortedSet类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了LongSortedSet类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: get

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
@Override
public SimpleItemItemModel get() {
	// Get the transposed rating matrix
	// This gives us a map of item IDs to those items' rating vectors
	Map<Long, ImmutableSparseVector> itemVectors = getItemVectors();

	// Get all items - you might find this useful
	LongSortedSet items = LongUtils.packedSet(itemVectors.keySet());
	// Map items to vectors of item similarities
	@SuppressWarnings("unused")
	Map<Long,MutableSparseVector> itemSimilarities = new HashMap<Long, MutableSparseVector>();

	// Compute the similarities between each pair of items
	// It will need to be in a map of longs to lists of Scored IDs to store in the model
	Map<Long, List<ScoredId>> neighborhoods = new HashMap<Long, List<ScoredId>>();


	// Compute the similarities between each pair of items
	CosineVectorSimilarity cosine = new CosineVectorSimilarity();

	for(long item : items){

		// get this item ratings
		ImmutableSparseVector itemRatings = itemVectors.get(item);

		// create the accumulator for this item
		TopNScoredItemAccumulator accumulator = new TopNScoredItemAccumulator(items.size() - 1);

		for(long neighbor : items){

			// skip itself
			if(item == neighbor) continue;

			ImmutableSparseVector neighRatings = itemVectors.get(neighbor);

			// cosine similarity
			double similarity = cosine.similarity(itemRatings, neighRatings);

			//accumulate positive similarities
			if(similarity >= 0.0){
				accumulator.put(neighbor, similarity);
			}
		}

		//get the final list of sorted neighbors
		List<ScoredId> similarities = accumulator.finish();

		// update the map of similarity
		neighborhoods.put(item, similarities);
	}

	// It will need to be in a map of longs to lists of Scored IDs to store in the model
	return new SimpleItemItemModel(neighborhoods);
}
 
开发者ID:paolobarbaglia,项目名称:coursera_recommender_systems,代码行数:55,代码来源:SimpleItemItemModelBuilder.java


示例2: get

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
@Override
public SimpleItemItemModel get() {
    // Get the transposed rating matrix
    // This gives us a map of item IDs to those items' rating vectors
    Map<Long, ImmutableSparseVector> itemVectors = getItemVectors();

    // Get all items - you might find this useful
    LongSortedSet items = LongUtils.packedSet(itemVectors.keySet());
    // Map items to vectors of item similarities
    Map<Long,MutableSparseVector> itemSimilarities = new HashMap<Long, MutableSparseVector>();

    // TODO Compute the similarities between each pair of items
    // It will need to be in a map of longs to lists of Scored IDs to store in the model
    return new SimpleItemItemModel(Collections.EMPTY_MAP);
}
 
开发者ID:4DD8A19D69F5324F9D49D17EF78BBBCC,项目名称:Introd_uction_to_Recom_mander_S_ystem,代码行数:16,代码来源:SimpleItemItemModelBuilder.java


示例3: keySet

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
public LongSortedSet keySet() {
	if (keys == null)
		keys = new KeySet();
	return keys;
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:6,代码来源:Long2ObjectRBNavigableMap.java


示例4: getItemUniverse

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
@Override
public LongSortedSet getItemUniverse() {
    return LongUtils.packedSet(itemDAO.getItemIds());
}
 
开发者ID:paolobarbaglia,项目名称:coursera_recommender_systems,代码行数:5,代码来源:LuceneItemItemModel.java


示例5: get

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
@Override
  public SimpleItemItemModel get() {
      // Get the transposed rating matrix
      // This gives us a map of item IDs to those items' rating vectors
      Map<Long, ImmutableSparseVector> itemVectors = getItemVectors();

      // Get all items - you might find this useful
      LongSortedSet items = LongUtils.packedSet(itemVectors.keySet());
      // Map items to vectors of item similarities
      //Map<Long,MutableSparseVector> itemSimilarities = new HashMap<Long, MutableSparseVector>();
Map<Long, List<ScoredId>> neighborhoods = new HashMap<Long, List<ScoredId>>();

// Computing the similarities between each pair of items
      // It will need to be in a map of longs to lists of Scored IDs to store in the model
for(Iterator outerIter = items.iterator(); outerIter.hasNext() ; ) {
	Long thisItemId = (Long) outerIter.next();

	TopNScoredItemAccumulator accumulator = new TopNScoredItemAccumulator(items.size()-1);

	// Calculate similiarity with other item one by one and
	for(Iterator innerIter = items.iterator(); innerIter.hasNext() ; ) {
		Long nghbrItemId = (Long) innerIter.next();

		if(thisItemId.equals(nghbrItemId)) continue;

		// cosine similarity
		double similarity = new CosineVectorSimilarity().similarity(itemVectors.get(thisItemId),
				itemVectors.get(nghbrItemId));

		//accumulate
		if (similarity > 0) {
			accumulator.put(nghbrItemId, similarity);
		}
	}
	//put in the final list of sorted neighbors
	List<ScoredId> similarities = accumulator.finish();
	neighborhoods.put(thisItemId, similarities);
}
return new SimpleItemItemModel(neighborhoods);
      //return new SimpleItemItemModel(Collections.EMPTY_MAP);
  }
 
开发者ID:rohitsinha54,项目名称:Coursera-Introduction-to-Recommender-Systems-Programming-Assignment-5,代码行数:42,代码来源:SimpleItemItemModelBuilder.java


示例6: getBidPrices

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
/**
 * Get the bid prices.
 *
 * @return the bid prices
 */
public LongSortedSet getBidPrices() {
    return bids.keySet();
}
 
开发者ID:paritytrading,项目名称:parity,代码行数:9,代码来源:OrderBook.java


示例7: getAskPrices

import it.unimi.dsi.fastutil.longs.LongSortedSet; //导入依赖的package包/类
/**
 * Get the ask prices.
 *
 * @return the ask prices
 */
public LongSortedSet getAskPrices() {
    return asks.keySet();
}
 
开发者ID:paritytrading,项目名称:parity,代码行数:9,代码来源:OrderBook.java



注:本文中的it.unimi.dsi.fastutil.longs.LongSortedSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DocumentImpl类代码示例发布时间:2022-05-22
下一篇:
Java OverrideAnnotationOf类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap