Пример #1
0
        public virtual double[] GetMeanMetrics(IDataEnumerator data, List <IMetric> metrics)
        {
            double[] vals = new double[metrics.Count];
            data.Reset();
            int count = 0;

            object lock_target = new object();

            Parallel.ForEach(data, (needed) =>
            {
                double[,,] output = GetOutput(needed.input);
                for (int i = 0; i < metrics.Count; i++)
                {
                    var m = metrics[i].Metric(output, needed.output);
                    lock (lock_target)
                    {
                        vals[i] += m;
                        count++;
                    }
                }
            });
            data.Reset();
            for (int i = 0; i < vals.Length; i++)
            {
                vals[i] /= count;
            }
            return(vals);
        }
Пример #2
0
        public virtual KeyValuePair <double, double> GetError(IDataEnumerator data)
        {
            data.Reset();
            double err   = 0;
            double wins  = 0;
            int    count = 0;

            object lock_target = new object();

            Parallel.ForEach(data, (needed) =>
            {
                var pair = GetErrorPair(needed.input, needed.output);
                lock (lock_target)
                {
                    err  += pair.Key;
                    wins += pair.Value;
                    count++;
                }
            });
            data.Reset();
            return(new KeyValuePair <double, double>(err / count, wins / count));
        }
Пример #3
0
        /// <summary>
        /// Возращает среднюю метрику metric по всему DataEnumerator
        /// </summary>
        /// <param name="data"></param>
        /// <param name="metric"></param>
        /// <returns></returns>
        public virtual double GetMeanMetric(IDataEnumerator data, IMetric metric)
        {
            data.Reset();
            double mean_metric = 0;
            int    count       = 0;

            object lock_target = new object();

            Parallel.ForEach(data, (needed) =>
            {
                double[,,] output = GetOutput(needed.input);
                var m             = metric.Metric(output, needed.output);
                lock (lock_target)
                {
                    mean_metric += m;
                    count++;
                }
            });
            data.Reset();
            mean_metric /= count;
            return(mean_metric);
        }
Пример #4
0
 public void Reset()
 {
     enumer.Reset();
 }