1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using HeuristicLab.DataAnalysis;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Modeling {
|
---|
29 | public class AnalyzerModel : IAnalyzerModel {
|
---|
30 | public AnalyzerModel() { } // for persistence
|
---|
31 |
|
---|
32 | #region IModel Members
|
---|
33 |
|
---|
34 | private Dataset dataset;
|
---|
35 | public Dataset Dataset {
|
---|
36 | get { return dataset; }
|
---|
37 | set { dataset = value; }
|
---|
38 | }
|
---|
39 |
|
---|
40 | private string targetVariable;
|
---|
41 | public string TargetVariable {
|
---|
42 | get { return targetVariable; }
|
---|
43 | set { targetVariable = value; }
|
---|
44 | }
|
---|
45 |
|
---|
46 | private List<string> inputVariables = new List<string>();
|
---|
47 | public IEnumerable<string> InputVariables {
|
---|
48 | get { return inputVariables; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public int TrainingSamplesStart { get; set; }
|
---|
52 | public int TrainingSamplesEnd { get; set; }
|
---|
53 | public int ValidationSamplesStart { get; set; }
|
---|
54 | public int ValidationSamplesEnd { get; set; }
|
---|
55 | public int TestSamplesStart { get; set; }
|
---|
56 | public int TestSamplesEnd { get; set; }
|
---|
57 |
|
---|
58 | public void AddInputVariable(string variableName) {
|
---|
59 | if (!inputVariables.Contains(variableName))
|
---|
60 | inputVariables.Add(variableName);
|
---|
61 | }
|
---|
62 |
|
---|
63 | private double trainingMSE;
|
---|
64 | public double TrainingMeanSquaredError {
|
---|
65 | get { return trainingMSE; }
|
---|
66 | set { trainingMSE = value; }
|
---|
67 | }
|
---|
68 |
|
---|
69 | private double validationMSE;
|
---|
70 | public double ValidationMeanSquaredError {
|
---|
71 | get { return validationMSE; }
|
---|
72 | set { validationMSE = value; }
|
---|
73 | }
|
---|
74 |
|
---|
75 | private double testMSE;
|
---|
76 | public double TestMeanSquaredError {
|
---|
77 | get { return testMSE; }
|
---|
78 | set { testMSE = value; }
|
---|
79 | }
|
---|
80 |
|
---|
81 | public double TrainingMeanAbsolutePercentageError {
|
---|
82 | get;
|
---|
83 | set;
|
---|
84 | }
|
---|
85 |
|
---|
86 | public double ValidationMeanAbsolutePercentageError {
|
---|
87 | get;
|
---|
88 | set;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public double TestMeanAbsolutePercentageError {
|
---|
92 | get;
|
---|
93 | set;
|
---|
94 | }
|
---|
95 |
|
---|
96 | public double TrainingMeanAbsolutePercentageOfRangeError {
|
---|
97 | get;
|
---|
98 | set;
|
---|
99 | }
|
---|
100 |
|
---|
101 | public double ValidationMeanAbsolutePercentageOfRangeError {
|
---|
102 | get;
|
---|
103 | set;
|
---|
104 | }
|
---|
105 |
|
---|
106 | public double TestMeanAbsolutePercentageOfRangeError {
|
---|
107 | get;
|
---|
108 | set;
|
---|
109 | }
|
---|
110 |
|
---|
111 | public double TrainingCoefficientOfDetermination {
|
---|
112 | get;
|
---|
113 | set;
|
---|
114 | }
|
---|
115 |
|
---|
116 | public double ValidationCoefficientOfDetermination {
|
---|
117 | get;
|
---|
118 | set;
|
---|
119 | }
|
---|
120 |
|
---|
121 | public double TestCoefficientOfDetermination {
|
---|
122 | get;
|
---|
123 | set;
|
---|
124 | }
|
---|
125 |
|
---|
126 | public double TrainingVarianceAccountedFor {
|
---|
127 | get;
|
---|
128 | set;
|
---|
129 | }
|
---|
130 |
|
---|
131 | public double ValidationVarianceAccountedFor {
|
---|
132 | get;
|
---|
133 | set;
|
---|
134 | }
|
---|
135 |
|
---|
136 | public double TestVarianceAccountedFor {
|
---|
137 | get;
|
---|
138 | set;
|
---|
139 | }
|
---|
140 |
|
---|
141 | public double GetVariableQualityImpact(string variableName) {
|
---|
142 | if (variableQualityImpacts.ContainsKey(variableName)) return variableQualityImpacts[variableName];
|
---|
143 | else throw new ArgumentException("Impact of variable " + variableName + " is not available.");
|
---|
144 | }
|
---|
145 |
|
---|
146 | public double GetVariableEvaluationImpact(string variableName) {
|
---|
147 | if (variableEvaluationImpacts.ContainsKey(variableName)) return variableEvaluationImpacts[variableName];
|
---|
148 | else throw new ArgumentException("Impact of variable " + variableName + " is not available.");
|
---|
149 | }
|
---|
150 |
|
---|
151 | public IPredictor Predictor { get; set; }
|
---|
152 |
|
---|
153 | #endregion
|
---|
154 |
|
---|
155 | private Dictionary<string, double> variableQualityImpacts = new Dictionary<string, double>();
|
---|
156 | public void SetVariableQualityImpact(string variableName, double impact) {
|
---|
157 | variableQualityImpacts[variableName] = impact;
|
---|
158 | }
|
---|
159 |
|
---|
160 | public void SetVariableQualityImpact(int variableIndex, double impact) {
|
---|
161 | variableQualityImpacts[dataset.GetVariableName(variableIndex)] = impact;
|
---|
162 | }
|
---|
163 |
|
---|
164 | private Dictionary<string, double> variableEvaluationImpacts = new Dictionary<string, double>();
|
---|
165 | public void SetVariableEvaluationImpact(string variableName, double impact) {
|
---|
166 | variableEvaluationImpacts[variableName] = impact;
|
---|
167 | }
|
---|
168 |
|
---|
169 | public void SetVariableEvaluationImpact(int variableIndex, double impact) {
|
---|
170 | variableEvaluationImpacts[dataset.GetVariableName(variableIndex)] = impact;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | }
|
---|