TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
RecallRanklistComputation.cs
Go to the documentation of this file.
1 // TraceLab Component Library
2 // Copyright © 2012-2013 SEMERU
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 using System.Linq;
18 using TraceLabSDK.Types;
19 using TraceLabSDK.Types.Contests;
20 
21 namespace TraceLab.Components.DevelopmentKit.Metrics.Traceability
22 {
27  {
28  #region Members
29 
30  private const string _name = "Recall (ranklist granularity)";
31  private const string _description = "Recall measures the fraction of correctly retrieved documents among the total correct documents. This metric is computed on the overall ranked list.";
32 
36  public override string Name
37  {
38  get { return _name; }
39  }
40 
44  public override string Description
45  {
46  get { return _description; }
47  }
48 
49  private TLSimilarityMatrix _matrix;
50  private TLSimilarityMatrix _oracle;
51 
52  #endregion
53 
59  public RecallRanklistComputation(TLSimilarityMatrix candidateMatrix, TLSimilarityMatrix answerMatrix)
60  {
61  _matrix = candidateMatrix;
62  _oracle = answerMatrix;
63  }
64 
68  protected override void ComputeImplementation()
69  {
70  _oracle.Threshold = 0;
71  int correct = 0;
72  foreach (TLSingleLink link in _matrix.AllLinks)
73  {
74  if (_oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId))
75  {
76  correct++;
77  }
78  }
79  Results = new TraceLabSDK.SerializableDictionary<string,double>();
80  Results.Add("Recall", correct / (double)_oracle.Count);
81  }
82 
87  protected override Metric GenerateSummaryImplementation()
88  {
89  BoxSummaryData data = new BoxSummaryData(Name, Description);
90  data.AddPoint(new BoxPlotPoint(Results.Values.ToArray()));
91  return data;
92  }
93  }
94 }