Exemplo n.º 1
0
        protected ConfusionMatrix Test(IRuleSystem rules, IEnumerable <Packet> testPackets)
        {
            var hits = new ConfusionMatrix();

            var locker = new Object();

            Parallel.ForEach(testPackets, p =>
            {
                var predict = rules.CheckType(p.ParseToPoint());
                var real    = p.Type;
                lock (locker)
                {
                    hits[real, predict]++;
                }
            });

            return(hits);
        }
Exemplo n.º 2
0
        public static long FastTest(IRuleSystem rules, IEnumerable <Packet> testPackets)
        {
            long hit = 0;

            var locker = new Object();

            Parallel.ForEach(testPackets, p =>
            {
                var guess = rules.CheckType(p.ParseToPoint());
                if (guess != p.Type)
                {
                    return;
                }
                lock (locker)
                {
                    hit++;
                }
            });

            return(hit);
        }
Exemplo n.º 3
0
        private ConfusionMatrix Test(IRuleSystem rules)
        {
            var parts = Directory.EnumerateFiles(_testDir);

            var hits = new ConfusionMatrix();

            var total = parts.Count();
            var cont  = 0;

            foreach (var filename in parts)
            {
                Debug.WriteLine("...[Testing Part {0} / {1}]", ++cont, total);

                var testPackets = Factory.Read(filename);
                TestAmt += testPackets.Count;

                var result = Test(rules, testPackets);

                //join parts
                hits += result; //WOW! operator overload!
            }
            return(hits);
        }