Esempio n. 1
0
        public static DataSetPairs Compute(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel level)
        {
            TLKeyValuePairsList precision;
            TLKeyValuePairsList recall;
            TLKeyValuePairsList avgPrecision;
            TLKeyValuePairsList meanAvgPrecision;

            ComputeMetrics(sims, oracle, level, out precision, out recall, out avgPrecision, out meanAvgPrecision);
            return(new DataSetPairs
            {
                Name = RecallLevelUtil.ShortRecallString(level),
                PrecisionData = precision,
                RecallData = recall,
                AveragePrecisionData = avgPrecision,
                MeanAveragePrecisionData = meanAvgPrecision,
            });
        }
Esempio n. 2
0
        public static TLLinksList GetLinksAtRecall(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel level)
        {
            double      totalCorrect = oracle.Count * RecallLevelUtil.RecallValue(level);
            int         numCorrect   = 0;
            TLLinksList list         = new TLLinksList();
            TLLinksList links        = sims.AllLinks;

            links.Sort();
            while (links.Count > 0 && numCorrect < totalCorrect)
            {
                TLSingleLink link = links[0];
                if (oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId))
                {
                    numCorrect++;
                }
                list.Add(link);
                links.RemoveAt(0);
            }
            return(list);
        }
Esempio n. 3
0
        public static void ComputeMetrics(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel level,
                                          out TLKeyValuePairsList precision, out TLKeyValuePairsList recall, out TLKeyValuePairsList avgPrecision, out TLKeyValuePairsList meanAvgPrecision)
        {
            TLLinksList links             = MetricsUtil.GetLinksAtRecall(sims, oracle, level);
            int         numCorrect        = 0;
            int         totalRead         = 0;
            double      totalAvgPrecision = 0.0;

            foreach (TLSingleLink link in links)
            {
                totalRead++;
                if (oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId))
                {
                    numCorrect++;
                    totalAvgPrecision += numCorrect / (double)totalRead;
                }
            }
            // temporary
            precision = new TLKeyValuePairsList();
            precision.Add(new KeyValuePair <string, double>("#TOTAL", numCorrect / Convert.ToDouble(links.Count)));
            recall = new TLKeyValuePairsList();
            recall.Add(new KeyValuePair <string, double>("#TOTAL", Math.Ceiling(oracle.Count * RecallLevelUtil.RecallValue(level)) / oracle.Count));
            avgPrecision = new TLKeyValuePairsList();
            avgPrecision.Add(new KeyValuePair <string, double>("#TOTAL", totalAvgPrecision / oracle.Count));
            meanAvgPrecision = new TLKeyValuePairsList();
            meanAvgPrecision.Add(new KeyValuePair <string, double>("#TOTAL", MeanAveragePrecision.Compute(Similarities.CreateMatrix(links), oracle)));
        }