Collection <GenericItemSimilarity.ItemItemSimilarity> correlations = ...;
2014-03-19 21:01
489 查看
粘自:http://stackoverflow.com/questions/8283439/mahout-recommender
oldest
votes
![](http://static.adzerk.net/Advertisers/a61df59863ed44e59446d0b9bb805c56.jpg)
![](http://engine.adzerk.net/i.gif?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giOjExNzgsImNyIjoxMDc2OCwiZGkiOiI3ODkyY2M1MmM5Mzk0NTRiYjI2YTk4MjhjZGM1MGNjNSIsImRtIjoxLCJmYyI6MTY4ODUsImZsIjoyNDQ0LCJrdyI6ImphdmEsbWFob3V0IiwibnciOjIyLCJwYyI6MCwicHIiOjE1NjgsInJ0IjoxLCJyZiI6IiBodHRwczovL3d3dy5nb29nbGUuY29tLmhrLyIsInN0Ijo4Mjc3LCJ6biI6NDQsInRzIjoxMzk1MjI4OTI3OTM0fQ&s=H9pvO0n_UfxOyov-WA_wfbzVeyQ)
No problem. We won't show you that ad again. Why didn't you like it?
Uninteresting
Misleading
Offensive
Repetitive
Oops! I didn't mean to do this.
The Apache Mahout Recommender Documentation mentions the following: // Construct the list of pre-computed correlations Collection <GenericItemSimilarity.ItemItemSimilarity> correlations = ...; I'm not sure how the actual construction is done in the above line. Can someone provide an example? ItemSimilarity itemSimilarity = new GenericItemSimilarity(correlations); java mahout
| |||
2 Answers
activeoldest
votes
up vote 2 down vote | This example refers to the case where you have the similarities already computed, by the Hadoop job for example, and stored on the filesystem or database . As the constructor documentation reads:A "generic" {@link ItemSimilarity} which takes a static list of precomputed item similarities and bases its responses on that alone. The values may have been precomputed offline by another process, stored in a file, and then read and fed into an instance of this class. If you have tens of millions of recommendations or less, you can simply compute similarities on the fly and use the other GenericItemSimilarityconstructor - GenericItemSimilarity(ItemSimilarity otherSimilarity, DataModel dataModel) For example: DataModel dataModel = new FileDataModel(new File("path://to/file.csv")); ItemSimilarity itemSimilarity = new LogLikelihoodSimilarity(dataModel); ItemSimilarity itemSimilarity = new GenericItemSimilarity(itemSimilarity, dataModel);
| |||
![](http://static.adzerk.net/Advertisers/a61df59863ed44e59446d0b9bb805c56.jpg)
![](http://engine.adzerk.net/i.gif?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giOjExNzgsImNyIjoxMDc2OCwiZGkiOiI3ODkyY2M1MmM5Mzk0NTRiYjI2YTk4MjhjZGM1MGNjNSIsImRtIjoxLCJmYyI6MTY4ODUsImZsIjoyNDQ0LCJrdyI6ImphdmEsbWFob3V0IiwibnciOjIyLCJwYyI6MCwicHIiOjE1NjgsInJ0IjoxLCJyZiI6IiBodHRwczovL3d3dy5nb29nbGUuY29tLmhrLyIsInN0Ijo4Mjc3LCJ6biI6NDQsInRzIjoxMzk1MjI4OTI3OTM0fQ&s=H9pvO0n_UfxOyov-WA_wfbzVeyQ)
No problem. We won't show you that ad again. Why didn't you like it?
Uninteresting
Misleading
Offensive
Repetitive
Oops! I didn't mean to do this.
up vote 1 down vote | There's no magic here, it's just suggesting you create a bunch of those ItemItemSimilarity objects, one for each item-item similarity that you know about.Collection<GenericItemSimilarity.ItemItemSimilarity> correlations = new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(); correlations.add(new GenericItemSimilarity.ItemItemSimilarity(1, 2, 0.5)); ... You can make it this way or any other way you want. |
相关文章推荐
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">属性的含义
- System.Collection.IList 转换成为 System.Collection.Generic.IList<T>
- mybatis中的<foreach collection="list" item="item" index="index" open="" close="" separator=";">
- Mybatis使用<foreach collection="***" item="**" open="(" separator="," close=")">问题
- NSGenericException', reason: '*** Collection <__NSArrayM: 0x12a9f7d0> was mutated while being enumer
- 并行集合--IProducerConsumerCollection<T>
- 关于ASP中用Repeater数据填充,<%#Eval() %>和<%#Container.DataItem()%>等方法的区别
- java.lang.NoSuchMethodError: org.apache.commons.pool.impl.GenericObjectPool: method <init>()V not fo
- android背景设置报错 <item> tag requires a 'drawable' attribute or child tag defining a drawable
- wpf list<T>与ObservableCollection<T>的区别
- <java API源码初体验>2---collection集合之LinkedList原理分析
- JDK源码(1.7) -- java.util.Collection<E>
- JDK源码(1.7) -- java.util.AbstractCollection<E>
- List<T>和ObservableCollection<T>的相互转化
- 黑马程序员_<<Collection,List>>
- c# generic的用法 class <T>
- 在hibernate中 以Collection<Entity> 替换Map<Key, List<Value>结构
- 不存在具有键“xxxId”的“IEnumerable<SelectListItem>”类型的 ViewData 项
- <13> go collection-func
- System.Collections.Generic.List<T> 与 System.Collections.ArrayList