public static HammingDistanceResultStatistics From(ConcurrentBag <int> truePositivesBag, ConcurrentBag <int> falseNegativesBag, ConcurrentBag <int> falsePositivesBag, double[] percentiles)
        {
            var truePositives = truePositivesBag.ToList();

            truePositives.Sort();
            var falseNegatives = falseNegativesBag.ToList();

            falseNegatives.Sort();
            var falsePositives = falsePositivesBag.ToList();

            falsePositives.Sort();

            var instance = new HammingDistanceResultStatistics()
            {
                TruePositivesAvg        = truePositives.DefaultIfEmpty(0).Average(),
                TruePositiveMin         = truePositives.DefaultIfEmpty(0).Min(),
                TruePositiveMax         = truePositives.DefaultIfEmpty(0).Max(),
                FalseNegativesAvg       = falseNegatives.DefaultIfEmpty(0).Average(),
                FalseNegativesMin       = falseNegatives.DefaultIfEmpty(0).Min(),
                FalseNegativesMax       = falseNegatives.DefaultIfEmpty(0).Max(),
                FalsePositiveAvg        = falsePositives.DefaultIfEmpty(0).Average(),
                FalsePositiveMin        = falsePositives.DefaultIfEmpty(0).Min(),
                FalsePositiveMax        = falsePositives.DefaultIfEmpty(0).Max(),
                TruePositivePercentile  = Percentiles(truePositives, percentiles),
                FalseNegativePercentile = Percentiles(falseNegatives, percentiles),
                FalsePositivePercentile = Percentiles(falsePositives, percentiles)
            };

            return(instance);
        }
 private TestRunnerEventArgs GetTestRunnerEventArgsForFinishedTestIteration(IStride queryStride, int seconds, List<int> startAts, FScore fscore, HammingDistanceResultStatistics statistics, int iteration, Stopwatch stopwatch, int verified)
 {
     return new TestRunnerEventArgs
         {
             FScore = fscore,
             RowWithDetails =
                 new object[]
                     {
                         this.GetInsertMetadata(), queryStride.ToString(), seconds, startAts[iteration],
                         fscore.Precision, fscore.Recall, fscore.F1,
                         statistics.TruePositiveInfo,
                         statistics.TruePositivePercentileInfo,
                         statistics.FalseNegativesInfo,
                         statistics.FalseNegativesPercentileInfo,
                         statistics.FalsePositivesInfo,
                         statistics.FalsePositivesPercentileInfo,
                         (double)stopwatch.ElapsedMilliseconds / 1000
                     },
             Verified = verified
         };
 }
        public static HammingDistanceResultStatistics From(ConcurrentBag<int> truePositivesBag, ConcurrentBag<int> falseNegativesBag, ConcurrentBag<int> falsePositivesBag, double[] percentiles)
        {
            var truePositives = truePositivesBag.ToList();
            truePositives.Sort();
            var falseNegatives = falseNegativesBag.ToList();
            falseNegatives.Sort();
            var falsePositives = falsePositivesBag.ToList();
            falsePositives.Sort();

            var instance = new HammingDistanceResultStatistics()
                {
                    TruePositivesAvg = truePositives.DefaultIfEmpty(0).Average(),
                    TruePositiveMin = truePositives.DefaultIfEmpty(0).Min(),
                    TruePositiveMax = truePositives.DefaultIfEmpty(0).Max(),
                    FalseNegativesAvg = falseNegatives.DefaultIfEmpty(0).Average(),
                    FalseNegativesMin = falseNegatives.DefaultIfEmpty(0).Min(),
                    FalseNegativesMax = falseNegatives.DefaultIfEmpty(0).Max(),
                    FalsePositiveAvg = falsePositives.DefaultIfEmpty(0).Average(),
                    FalsePositiveMin = falsePositives.DefaultIfEmpty(0).Min(),
                    FalsePositiveMax = falsePositives.DefaultIfEmpty(0).Max(),
                    TruePositivePercentile = Percentiles(truePositives, percentiles),
                    FalseNegativePercentile = Percentiles(falseNegatives, percentiles),
                    FalsePositivePercentile = Percentiles(falsePositives, percentiles)
                };

            return instance;
        }