コード例 #1
0
 public RecommendedBecauseEstimator(User user,
                                    Item recommendedItem,
                                    ItemCorrelation correlation)
 {
     this.user            = user;
     this.recommendedItem = recommendedItem;
     this.correlation     = correlation;
 }
コード例 #2
0
 public MultiMostSimilarEstimator(List <Item> toItems,
                                  ItemCorrelation correlation,
                                  Rescorer <Pair <Item, Item> > rescorer)
 {
     this.toItems     = toItems;
     this.correlation = correlation;
     this.rescorer    = rescorer;
 }
コード例 #3
0
 internal MostSimilarEstimator(Item toItem,
                               ItemCorrelation correlation,
                               Rescorer <Pair <Item, Item> > rescorer)
 {
     this.toItem      = toItem;
     this.correlation = correlation;
     this.rescorer    = rescorer;
 }
コード例 #4
0
 public GenericItemBasedRecommender(DataModel dataModel, ItemCorrelation correlation)
     : base(dataModel)
 {
     if (correlation == null)
     {
         throw new ArgumentNullException("Correlation is null");
     }
     this.correlation = correlation;
     this.refreshLock = new ReentrantLock();
 }
コード例 #5
0
        /// <summary>
        /// <p>Builds a list of item-item correlations given an {@link ItemCorrelation} implementation and a
        /// <see cref="DataModel">DataModel</see>, rather than a list of {@link ItemItemCorrelation}s.</p>
        /// <p>It's valid to build a <see cref="GenericItemCorrelation"/> this way, but perhaps missing some of the point
        /// of an item-based Recommender. Item-based recommenders use the assumption that item-item correlations
        /// are relatively fixed, and might be known already independent of user preferences. Hence it is useful
        /// to inject that information, using {@link GenericItemCorrelation(java.util.Collection)}.</p>
        /// </summary>
        /// <param name="otherCorrelation">otherCorrelation other {@link ItemCorrelation} to get correlations from</param>
        /// <param name="dataModel">dataModel data Model to get {@link Item}s from</param>
        public GenericItemCorrelation(ItemCorrelation otherCorrelation, DataModel dataModel)
        {
            List <Item> items = EnumeratorUtils.EnumerableToList <Item>(dataModel.GetItems());
            int         size  = items.Count;

            for (int i = 0; i < size; i++)
            {
                Item item1 = items[i];
                for (int j = i + 1; j < size; j++)
                {
                    Item   item2                  = items[j];
                    double correlation            = otherCorrelation.GetItemCorrelation(item1, item2);
                    Dictionary <Item, Double> map = null;
                    if (!correlationMaps.TryGetValue(item1, out map))
                    {
                        map = new Dictionary <Item, Double>(1009);
                        correlationMaps.Add(item1, map);
                    }
                    map.Add(item2, correlation);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// <p>Builds a list of item-item correlations given an {@link ItemCorrelation} implementation and a
        /// <see cref="DataModel">DataModel</see>, rather than a list of {@link ItemItemCorrelation}s.</p>
        /// <p>It's valid to build a <see cref="GenericItemCorrelation"/> this way, but perhaps missing some of the point 
        /// of an item-based Recommender. Item-based recommenders use the assumption that item-item correlations
        /// are relatively fixed, and might be known already independent of user preferences. Hence it is useful
        /// to inject that information, using {@link GenericItemCorrelation(java.util.Collection)}.</p>
        /// </summary>
        /// <param name="otherCorrelation">otherCorrelation other {@link ItemCorrelation} to get correlations from</param>
        /// <param name="dataModel">dataModel data Model to get {@link Item}s from</param>
		public GenericItemCorrelation(ItemCorrelation otherCorrelation, DataModel dataModel)
		{
			List<Item> items = EnumeratorUtils.EnumerableToList<Item>(dataModel.GetItems());
			int size = items.Count;
			for (int i = 0; i < size; i++) 
            {
				Item item1 = items[i];
				for (int j = i + 1; j < size; j++) 
                {
					Item item2 = items[j];
					double correlation = otherCorrelation.GetItemCorrelation(item1, item2);
					Dictionary<Item, Double> map = null;
					if (!correlationMaps.TryGetValue(item1, out map)) 
                    {
						map = new Dictionary<Item, Double>(1009);
						correlationMaps.Add(item1, map);
					}
					map.Add(item2, correlation);
				}
			}
		}