Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling/3.2/Model.cs @ 2273

Last change on this file since 2273 was 2270, checked in by gkronber, 15 years ago

Added properties for the separation in training/validation/test set to HL.Modeling.IModel. #712

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