public ItemSimilarityCalculator(IBehaviorStore behaviorStore, IItemPopularityProvider popularityProvider)
        {
            _behaviorStore      = behaviorStore;
            _popularityProvider = popularityProvider;

            TimeAttenuationAlpha   = .0002f;
            PopularItemPunishAlpha = .6f;
        }
Exemplo n.º 2
0
        public ItemSimilarityCalculator(IBehaviorStore behaviorStore, IItemPopularityProvider popularityProvider)
        {
            _behaviorStore = behaviorStore;
            _popularityProvider = popularityProvider;

            TimeAttenuationAlpha = .0002f;
            PopularItemPunishAlpha = .6f;
        }
Exemplo n.º 3
0
        public static void Register(string instance, string behaviorType, IBehaviorStore store)
        {
            if (!_storesByInstances.ContainsKey(instance))
            {
                _storesByInstances.Add(instance, new Dictionary<string, IBehaviorStore>());
            }

            var storesByBehavior = _storesByInstances[instance];
            if (storesByBehavior.ContainsKey(behaviorType))
            {
                storesByBehavior[behaviorType] = store;
            }
            else
            {
                storesByBehavior.Add(behaviorType, store);
            }
        }
Exemplo n.º 4
0
        public static void Register(string instance, string behaviorType, IBehaviorStore store)
        {
            if (!_storesByInstances.ContainsKey(instance))
            {
                _storesByInstances.Add(instance, new Dictionary <string, IBehaviorStore>());
            }

            var storesByBehavior = _storesByInstances[instance];

            if (storesByBehavior.ContainsKey(behaviorType))
            {
                storesByBehavior[behaviorType] = store;
            }
            else
            {
                storesByBehavior.Add(behaviorType, store);
            }
        }
Exemplo n.º 5
0
        private void Recompute(ISimilarityMatrix matrix, IBehaviorStore behaviorStore)
        {
            var allItems = behaviorStore.GetAllItems().ToList();

            if (allItems.Count == 0)
            {
                return;
            }

            var calculator = new ItemSimilarityCalculator(behaviorStore, NullItemPopularityProvider.Instance);
            var batch      = new Dictionary <ItemPair, double>();

            for (var i = 0; i < allItems.Count; i++)
            {
                for (var j = i + 1; j < allItems.Count; j++)
                {
                    var item1 = allItems[i];
                    var item2 = allItems[j];

                    var similarity = calculator.CalculateSimilarity(item1, item2);
                    if (similarity > 0)
                    {
                        batch.Add(new ItemPair(item1, item2), similarity);

                        if (batch.Count == _updateBatchSize)
                        {
                            matrix.AddSimilarities(batch);
                            batch.Clear();
                        }
                    }
                }
            }

            if (batch.Count > 0)
            {
                matrix.AddSimilarities(batch);
            }
        }
        private void Recompute(ISimilarityMatrix matrix, IBehaviorStore behaviorStore)
        {
            var allItems = behaviorStore.GetAllItems().ToList();
            if (allItems.Count == 0)
            {
                return;
            }

            var calculator = new ItemSimilarityCalculator(behaviorStore, NullItemPopularityProvider.Instance);
            var batch = new Dictionary<ItemPair, double>();

            for (var i = 0; i < allItems.Count; i++)
            {
                for (var j = i + 1; j < allItems.Count; j++)
                {
                    var item1 = allItems[i];
                    var item2 = allItems[j];

                    var similarity = calculator.CalculateSimilarity(item1, item2);
                    if (similarity > 0)
                    {
                        batch.Add(new ItemPair(item1, item2), similarity);

                        if (batch.Count == _updateBatchSize)
                        {
                            matrix.AddSimilarities(batch);
                            batch.Clear();
                        }
                    }
                }
            }

            if (batch.Count > 0)
            {
                matrix.AddSimilarities(batch);
            }
        }
 public BehaviorConfigurator(IBehaviorStore behaviorStore)
 {
     _behaviorStore = behaviorStore;
 }
Exemplo n.º 8
0
		public BehaviorConfigurator(IBehaviorStore behaviorStore)
		{
			_behaviorStore = behaviorStore;
		}