TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
EffectivenessBestMeasureComputation.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;
18 using System.Collections.Generic;
19 using System.Linq;
20 using System.Text;
21 using TraceLabSDK;
22 using TraceLabSDK.Types;
23 using TraceLabSDK.Types.Contests;
24 
25 namespace TraceLab.Components.DevelopmentKit.Metrics.FeatureLocation
26 {
31  {
32  #region Members
33 
34  private const string _name = "Effectiveness Best Measure";
35  private const string _description = "Computes the position of the highest ranked correct link. This metric is calculated per query.";
36 
40  public override string Name
41  {
42  get { return _name; }
43  }
44 
48  public override string Description
49  {
50  get { return _description; }
51  }
52 
53  private TLSimilarityMatrix _matrix;
54  private TLSimilarityMatrix _oracle;
55 
56  #endregion
57 
63  public EffectivenessBestMeasureComputation(TLSimilarityMatrix candidateMatrix, TLSimilarityMatrix answerMatrix)
64  : base()
65  {
66  _matrix = candidateMatrix;
67  _oracle = answerMatrix;
68  }
69 
73  protected override void ComputeImplementation()
74  {
75  _oracle.Threshold = 0;
76  Results = new SerializableDictionary<string, double>();
77  foreach (string query in _oracle.SourceArtifactsIds)
78  {
79  TLLinksList links = _matrix.GetLinksAboveThresholdForSourceArtifact(query);
80  links.Sort();
81  for (int i = 0; i < links.Count; i++)
82  {
83  if (_oracle.IsLinkAboveThreshold(query, links[i].TargetArtifactId))
84  {
85  Results.Add(query, i);
86  break;
87  }
88  }
89  }
90  }
91 
96  protected override Metric GenerateSummaryImplementation()
97  {
98  BoxSummaryData data = new BoxSummaryData(Name, Description);
99  data.AddPoint(new BoxPlotPoint(Results.Values.ToArray()));
100  return data;
101  }
102  }
103 }