TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
FeatureLocationMetricsComponent.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 TraceLab.Components.DevelopmentKit.Metrics;
22 using TraceLab.Components.DevelopmentKit.Metrics.FeatureLocation;
23 using TraceLab.Components.Library.Metrics.Controller;
24 using TraceLabSDK;
25 using TraceLabSDK.Types;
26 using TraceLabSDK.Types.Contests;
27 
28 namespace TraceLab.Components.Library.Metrics.FeatureLocation
29 {
30  [Component(Name = "Feature Location Metrics",
31  Description = "Computes various feature location metrics on a similarity matrix.",
32  Author = "SEMERU; Evan Moritz",
33  Version = "1.0.0.0",
34  ConfigurationType = typeof(FeatureLocationMetricsConfig))]
35  [IOSpec(IOSpecType.Input, "CandidateMatrix", typeof(TLSimilarityMatrix))]
36  [IOSpec(IOSpecType.Input, "AnswerMatrix", typeof(TLSimilarityMatrix))]
37  [Tag("Metrics.FeatureLocation")]
38  public class FeatureLocationMetricsComponent : BaseComponent
39  {
40  private FeatureLocationMetricsConfig _config;
41 
42  public FeatureLocationMetricsComponent(ComponentLogger log)
43  : base(log)
44  {
45  _config = new FeatureLocationMetricsConfig();
46  Configuration = _config;
47  }
48 
49  public override void Compute()
50  {
51  Logger.Trace("Starting metrics computation: " + _config.TechniqueName);
52  TLSimilarityMatrix matrix = (TLSimilarityMatrix)Workspace.Load("CandidateMatrix");
53  TLSimilarityMatrix oracle = (TLSimilarityMatrix)Workspace.Load("AnswerMatrix");
54  TLExperimentResults exResults = new TLExperimentResults(_config.TechniqueName);
55  #region Effectiveness Best Measure
56  if (_config.EffectivenessBestMeasure)
57  {
58  Logger.Trace("Computing effectiveness best measure...");
59  IMetricComputation computation = new EffectivenessBestMeasureComputation(matrix, oracle);
60  computation.Compute();
61  ResultsController.Instance.AddResult(_config.TechniqueName, _config.DatasetName, computation);
62  }
63  else
64  {
65  Logger.Trace("Skipped effectiveness best measure computation.");
66  }
67  #endregion
68  #region Effectiveness All Measure
69  if (_config.EffectivenessAllMeasure)
70  {
71  Logger.Trace("Computing effectiveness all measure...");
72  IMetricComputation computation = new EffectivenessAllMeasureComputation(matrix, oracle);
73  computation.Compute();
74  ResultsController.Instance.AddResult(_config.TechniqueName, _config.DatasetName, computation);
75  }
76  else
77  {
78  Logger.Trace("Skipped effectiveness all measure computation.");
79  }
80  #endregion
81  }
82  }
83 }