Пример #1
0
        private IDictionary<Type, TypedLearningPair> GetRandomNegativePairs(HistorySnapshot snapshot)
        {
            IDictionary<Type, TypedLearningPair> learningDict = new Dictionary<Type, TypedLearningPair>();
            int count = snapshot.Events.Count;
            int types = Enum.GetNames(typeof(EventName)).Length;
            Random rnd = new Random();
            for (int i = 0; i < count; i++)
            {
                string name = ((EventName) rnd.Next(types)).ToString();
                Type type = Significator.ToSignificantType(name);
                if (type == null)
                    continue;

                TypedLearningPair pair;
                if (!learningDict.ContainsKey(type))
                {
                    pair = new TypedLearningPair(type, false);
                    learningDict.Add(type, pair);
                }
                else
                {
                    pair = learningDict[type];
                }
                pair.Modify(Significator.ToSignificant(name));
            }
            return learningDict;
        }
Пример #2
0
        private IDictionary<Type, TypedLearningPair> GetPairs(HistorySnapshot snapshot, bool isTarget)
        {
            IDictionary<Type, TypedLearningPair> learningDict = new Dictionary<Type, TypedLearningPair>();
            foreach (IProcessAction action in snapshot.Events)
            {
                Type type = Significator.ToSignificantType(action.EventName);
                if (type == null)
                    continue;

                TypedLearningPair pair;
                if (!learningDict.ContainsKey(type))
                {
                    pair = new TypedLearningPair(type, isTarget);
                    learningDict.Add(type, pair);
                }
                else
                {
                    pair = learningDict[type];
                }
                pair.Modify(Significator.ToSignificant(action.EventName));
            }
            return learningDict;
        }