コード例 #1
0
        /// <summary>
        /// Computes the score for the given current results.
        /// </summary>
        /// <param name="baselineMatrices">The baseline matrices.</param>
        /// <param name="currentResults">The current results.</param>
        /// <returns></returns>
        public static double ComputeScore(TLSimilarityMatricesCollection baselineMatrices, TLSimilarityMatricesCollection currentResultsMatrices,
                                          TLDatasetsList datasets, MetricComputationComponentConfig config)
        {
            double score = 0.0;

            double sum    = 0;
            double counts = 0;

            IMetricComputation metricComputation = GetMetricComputation(config);

            foreach (TLDataset dataset in datasets)
            {
                TLSimilarityMatrix baseline = baselineMatrices[dataset.Name];
                TLSimilarityMatrix current  = currentResultsMatrices[dataset.Name];

                //score is computed based on delta between two techniques from metric computation
                SortedDictionary <string, double> baselineValues = metricComputation.Calculate(baseline, dataset);
                SortedDictionary <string, double> currentValues  = metricComputation.Calculate(current, dataset);

                var deltas = ScoreComputationHelper.Delta(baselineValues, currentValues);

                //now compute average of computed deltas, and that's the score

                foreach (double delta in deltas.Values)
                {
                    sum += delta;
                }

                counts += deltas.Count;
            }

            score = sum / counts;

            return(score);
        }
コード例 #2
0
        /// <summary>
        /// Computes the score for the given current results.
        /// </summary>
        /// <param name="baselineMatrices">The baseline matrices.</param>
        /// <param name="currentResults">The current results.</param>
        /// <returns></returns>
        public static double ComputeScore(TLSimilarityMatricesCollection baselineMatrices, TLSimilarityMatricesCollection currentResultsMatrices, 
                                          TLDatasetsList datasets, MetricComputationComponentConfig config)
        {
            double score = 0.0;

            double sum = 0;
            double counts = 0;

            IMetricComputation metricComputation = GetMetricComputation(config);

            foreach (TLDataset dataset in datasets)
            {
                TLSimilarityMatrix baseline = baselineMatrices[dataset.Name];
                TLSimilarityMatrix current = currentResultsMatrices[dataset.Name];

                //score is computed based on delta between two techniques from metric computation
                SortedDictionary<string, double> baselineValues = metricComputation.Calculate(baseline, dataset);
                SortedDictionary<string, double> currentValues = metricComputation.Calculate(current, dataset);

                var deltas = ScoreComputationHelper.Delta(baselineValues, currentValues);

                //now compute average of computed deltas, and that's the score

                foreach (double delta in deltas.Values)
                {
                    sum += delta;
                }

                counts += deltas.Count;
            }

            score = sum / counts;

            return score;
        }
コード例 #3
0
 /// <summary>
 /// Gets the metric computation.
 /// </summary>
 /// <param name="config">The config.</param>
 /// <returns></returns>
 private static IMetricComputation GetMetricComputation(MetricComputationComponentConfig config)
 {
     IMetricComputation metricComputation;
     if (config.ScoreBaseMetric == ScoreBaseMetric.PrecisionAtRecall100)
     {
         metricComputation = new PrecisionAtRecall100();
     }
     else if (config.ScoreBaseMetric == ScoreBaseMetric.Precision)
     {
         metricComputation = new Precision(config.Threshold);
     }
     else if (config.ScoreBaseMetric == ScoreBaseMetric.Recall)
     {
         metricComputation = new Recall(config.Threshold);
     }
     else
     {
         metricComputation = new AveragePrecision();
     }
     return metricComputation;
 }
コード例 #4
0
        /// <summary>
        /// Gets the metric computation.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <returns></returns>
        private static IMetricComputation GetMetricComputation(MetricComputationComponentConfig config)
        {
            IMetricComputation metricComputation;

            if (config.ScoreBaseMetric == ScoreBaseMetric.PrecisionAtRecall100)
            {
                metricComputation = new PrecisionAtRecall100();
            }
            else if (config.ScoreBaseMetric == ScoreBaseMetric.Precision)
            {
                metricComputation = new Precision(config.Threshold);
            }
            else if (config.ScoreBaseMetric == ScoreBaseMetric.Recall)
            {
                metricComputation = new Recall(config.Threshold);
            }
            else
            {
                metricComputation = new AveragePrecision();
            }
            return(metricComputation);
        }
コード例 #5
0
        //public MetricComputationEngine(GroupOfTracingResults<SingleTracingResults> allTracingResults, TLDatasetsList datasets, ComponentLogger logger)
        //    : this(allTracingResults, datasets, logger, 0.01)
        //{
        //}

        //public MetricComputationEngine(GroupOfTracingResults<SingleTracingResults> allTracingResults, TLDatasetsList datasets, ComponentLogger logger, double threshold)
        //    : base(allTracingResults, datasets)
        //{
        //    m_logger = logger;
        //    InitMetricComputationsPerDataset(threshold);
        //    InitMetricComputationAcrossAllDatasets();
        //}

        private void InitMetricComputationsPerDataset(MetricComputationComponentConfig config)
        {
            if (config.AveragePrecision == true)
            {
                RegisterMetricComputation(new AveragePrecisionMetricComputation(m_logger));
            }
            if (config.Recall == true)
            {
                RegisterMetricComputation(new RecallMetricComputation(config.Threshold, m_logger));
            }
            if (config.Precision == true)
            {
                RegisterMetricComputation(new PrecisionMetricComputation(config.Threshold, m_logger));
            }
            if (config.PrecisionAtRecall100 == true)
            {
                RegisterMetricComputation(new PrecisionAtRecall100MetricComputation(m_logger));
            }
            if (config.PrecisionRecallCurve == true)
            {
                RegisterMetricComputation(new PrecisionRecallCurveMetricComputation(m_logger));
            }
            //RegisterMetricComputation(new DataStatisticsMetricSingleDatasetComputation<SingleTracingResults>());
        }
コード例 #6
0
 public MetricComputationComponent(ComponentLogger log) : base(log) 
 {
     m_config = new MetricComputationComponentConfig();
     Configuration = m_config;
 }
コード例 #7
0
 public MetricComputationComponentForSingleDataset(ComponentLogger log) : base(log)
 {
     m_config      = new MetricComputationComponentConfig();
     Configuration = m_config;
 }
コード例 #8
0
        public MetricComputationEngine(TLDatasetsList datasets, ComponentLogger logger, MetricComputationComponentConfig config)
            : base(datasets)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            m_logger = logger;
            InitMetricComputationsPerDataset(config);
        }