Ejemplo n.º 1
0
        public StreamReader ReadData(string filename, StreamReader sr)
        {
            _classes   = new Dictionary <int, ResultAccumulator>();
            _summary   = new ResultAccumulator(_summaryClass);
            _outReject = new ResultAccumulator(_outRejectClass);

            if (null == sr)
            {
                sr = File.OpenText(filename);
            }

            string line;

            while (true)
            {
                line = sr.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int      iField = 0;;
                string[] fields = line.Split();

                int id     = Convert.ToInt32(fields[iField++]);
                int target = Convert.ToInt32(fields[iField++]);
                int output = Convert.ToInt32(fields[iField++]);
                ResultAccumulator res;

                if (_classes.ContainsKey(target))
                {
                    res = _classes[target];
                }
                else
                {
                    res = new ResultAccumulator(target);
                    _classes.Add(target, res);
                }

                if (_reject == output)
                {
                    _outReject.AddBinaryResult(target, output);
                }

                res.AddBinaryResult(target, output);
                _summary.AddBinaryResult(target, output);
            }

            if (_summary.Total <= 0)
            {
                sr.Close();
                sr = null;
            }
            return(sr);
        }
Ejemplo n.º 2
0
        public void Report(int verbose)
        {
            ResultAccumulator stats    = new ResultAccumulator(0);
            ResultAccumulator statsRej = new ResultAccumulator(0);

            foreach (KeyValuePair <int, ResultAccumulator> kv in _classes)
            {
                if (verbose > 1)
                {
                    Console.WriteLine("{0} {1} {2:F3}", kv.Value.ID, kv.Value.Total, kv.Value.ErrorRate);
                }
                stats.AddRealResult(kv.Value.ErrorRate);
                statsRej.AddRealResult(kv.Value.Reject);
            }

            Console.Write("{0} {1} {2:F3} ", _summary.Total, _summary.Correct, _summary.ErrorRate);
            Console.Write("{0} {1:F3} ", _outReject.Total, statsRej.Average);
            Console.WriteLine("{0:F3} {1:F3} {2:F3} {3:F3} ", stats.Average, stats.StdDev, stats.Min, stats.Max);
        }