Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Classification-Extensions/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationPerformanceMeasuresResultCollection.cs @ 11684

Last change on this file since 11684 was 11684, checked in by ehopf, 9 years ago

#2278: Encapsulated the classification performance measures to the ClassificationPerformanceMeasuresResultCollection

File size: 8.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Data;
23using HeuristicLab.Optimization;
24using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
25
26namespace HeuristicLab.Problems.DataAnalysis {
27  [StorableClass]
28  public class ClassificationPerformanceMeasuresResultCollection : ResultCollection {
29    #region result names
30    protected const string ClassificationPositiveClassValueResultName = "Classification positive class";
31    protected const string TrainingTruePositiveRateResultName = "True positive rate (training)";
32    protected const string TrainingTrueNegativeRateResultName = "True negative rate (training)";
33    protected const string TrainingPositivePredictiveValueResultName = "Positive predictive value (training)";
34    protected const string TrainingNegativePredictiveValueResultName = "Negative predictive value (training)";
35    protected const string TrainingFalsePositiveRateResultName = "False positive rate (training)";
36    protected const string TrainingFalseDiscoveryRateResultName = "False discovery rate (training)";
37    protected const string TestTruePositiveRateResultName = "True positive rate (test)";
38    protected const string TestTrueNegativeRateResultName = "True negative rate (test)";
39    protected const string TestPositivePredictiveValueResultName = "Positive predictive value (test)";
40    protected const string TestNegativePredictiveValueResultName = "Negative predictive value (test)";
41    protected const string TestFalsePositiveRateResultName = "False positive rate (test)";
42    protected const string TestFalseDiscoveryRateResultName = "False discovery rate (test)";
43    #endregion
44
45    public ClassificationPerformanceMeasuresResultCollection()
46      : base() {
47      AddMeasures();
48    }
49    [StorableConstructor]
50    protected ClassificationPerformanceMeasuresResultCollection(bool deserializing)
51      : base(deserializing) {
52    }
53
54    #region result properties
55    public string ClassificationPositiveClassValue {
56      get { return ((StringValue)this[ClassificationPositiveClassValueResultName].Value).Value; }
57      set { ((StringValue)this[ClassificationPositiveClassValueResultName].Value).Value = value; }
58    }
59    public double TrainingTruePositiveRate {
60      get { return ((DoubleValue)this[TrainingTruePositiveRateResultName].Value).Value; }
61      set { ((DoubleValue)this[TrainingTruePositiveRateResultName].Value).Value = value; }
62    }
63    public double TrainingTrueNegativeRate {
64      get { return ((DoubleValue)this[TrainingTrueNegativeRateResultName].Value).Value; }
65      set { ((DoubleValue)this[TrainingTrueNegativeRateResultName].Value).Value = value; }
66    }
67    public double TrainingPositivePredictiveValue {
68      get { return ((DoubleValue)this[TrainingPositivePredictiveValueResultName].Value).Value; }
69      set { ((DoubleValue)this[TrainingPositivePredictiveValueResultName].Value).Value = value; }
70    }
71    public double TrainingNegativePredictiveValue {
72      get { return ((DoubleValue)this[TrainingNegativePredictiveValueResultName].Value).Value; }
73      set { ((DoubleValue)this[TrainingNegativePredictiveValueResultName].Value).Value = value; }
74    }
75    public double TrainingFalsePositiveRate {
76      get { return ((DoubleValue)this[TrainingFalsePositiveRateResultName].Value).Value; }
77      set { ((DoubleValue)this[TrainingFalsePositiveRateResultName].Value).Value = value; }
78    }
79    public double TrainingFalseDiscoveryRate {
80      get { return ((DoubleValue)this[TrainingFalseDiscoveryRateResultName].Value).Value; }
81      set { ((DoubleValue)this[TrainingFalseDiscoveryRateResultName].Value).Value = value; }
82    }
83    public double TestTruePositiveRate {
84      get { return ((DoubleValue)this[TestTruePositiveRateResultName].Value).Value; }
85      set { ((DoubleValue)this[TestTruePositiveRateResultName].Value).Value = value; }
86    }
87    public double TestTrueNegativeRate {
88      get { return ((DoubleValue)this[TestTrueNegativeRateResultName].Value).Value; }
89      set { ((DoubleValue)this[TestTrueNegativeRateResultName].Value).Value = value; }
90    }
91    public double TestPositivePredictiveValue {
92      get { return ((DoubleValue)this[TestPositivePredictiveValueResultName].Value).Value; }
93      set { ((DoubleValue)this[TestPositivePredictiveValueResultName].Value).Value = value; }
94    }
95    public double TestNegativePredictiveValue {
96      get { return ((DoubleValue)this[TestNegativePredictiveValueResultName].Value).Value; }
97      set { ((DoubleValue)this[TestNegativePredictiveValueResultName].Value).Value = value; }
98    }
99    public double TestFalsePositiveRate {
100      get { return ((DoubleValue)this[TestFalsePositiveRateResultName].Value).Value; }
101      set { ((DoubleValue)this[TestFalsePositiveRateResultName].Value).Value = value; }
102    }
103    public double TestFalseDiscoveryRate {
104      get { return ((DoubleValue)this[TestFalseDiscoveryRateResultName].Value).Value; }
105      set { ((DoubleValue)this[TestFalseDiscoveryRateResultName].Value).Value = value; }
106    }
107    #endregion
108
109    protected void AddMeasures() {
110      Add(new Result(ClassificationPositiveClassValueResultName, "The positive class which is used for the performance measure calculations.", new StringValue()));
111      Add(new Result(TrainingTruePositiveRateResultName, "Sensitivity/True positive rate of the model on the training partition\n(TP/(TP+FN)).", new PercentValue()));
112      Add(new Result(TrainingTrueNegativeRateResultName, "Specificity/True negative rate of the model on the training partition\n(TN/(FP+TN)).", new PercentValue()));
113      Add(new Result(TrainingPositivePredictiveValueResultName, "Precision/Positive predictive value of the model on the training partition\n(TP/(TP+FP)).", new PercentValue()));
114      Add(new Result(TrainingNegativePredictiveValueResultName, "Negative predictive value of the model on the training partition\n(TN/(TN+FN)).", new PercentValue()));
115      Add(new Result(TrainingFalsePositiveRateResultName, "The false positive rate is the complement of the true negative rate of the model on the training partition.", new PercentValue()));
116      Add(new Result(TrainingFalseDiscoveryRateResultName, "The false discovery rate is the complement of the positive predictive value of the model on the training partition.", new PercentValue()));
117      Add(new Result(TestTruePositiveRateResultName, "Sensitivity/True positive rate of the model on the test partition\n(TP/(TP+FN)).", new PercentValue()));
118      Add(new Result(TestTrueNegativeRateResultName, "Specificity/True negative rate of the model on the test partition\n(TN/(FP+TN)).", new PercentValue()));
119      Add(new Result(TestPositivePredictiveValueResultName, "Precision/Positive predictive value of the model on the test partition\n(TP/(TP+FP)).", new PercentValue()));
120      Add(new Result(TestNegativePredictiveValueResultName, "Negative predictive value of the model on the test partition\n(TN/(TN+FN)).", new PercentValue()));
121      Add(new Result(TestFalsePositiveRateResultName, "The false positive rate is the complement of the true negative rate of the model on the test partition.", new PercentValue()));
122      Add(new Result(TestFalseDiscoveryRateResultName, "The false discovery rate is the complement of the positive predictive value of the model on the test partition.", new PercentValue()));
123      TrainingTruePositiveRate = double.NaN;
124      TrainingTrueNegativeRate = double.NaN;
125      TrainingPositivePredictiveValue = double.NaN;
126      TrainingNegativePredictiveValue = double.NaN;
127      TrainingFalsePositiveRate = double.NaN;
128      TrainingFalseDiscoveryRate = double.NaN;
129      TestTruePositiveRate = double.NaN;
130      TestTrueNegativeRate = double.NaN;
131      TestPositivePredictiveValue = double.NaN;
132      TestNegativePredictiveValue = double.NaN;
133      TestFalsePositiveRate = double.NaN;
134      TestFalseDiscoveryRate = double.NaN;
135    }
136  }
137}
Note: See TracBrowser for help on using the repository browser.