Changeset 15024 for trunk/sources
- Timestamp:
- 06/03/17 19:32:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r14943 r15024 20 20 #endregion 21 21 using System; 22 using System.Collections.Generic; 22 23 using System.Drawing; 23 24 using System.Linq; 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Data; 25 27 using HeuristicLab.MainForm; … … 86 88 var ds = problemData.Dataset; 87 89 var runs = new RunCollection(); 90 // determine relevant variables (at least two different values) 91 var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Max() > ds.GetDoubleValues(vn).Min()).ToArray(); 92 var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray(); 93 88 94 // produce training and test values separately as they might overlap (e.g. for ensembles) 89 95 var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray(); 90 96 int j = 0; // idx for predictedValues array 91 97 foreach (var i in problemData.TrainingIndices) { 92 var run = CreateRunForIdx(i, problemData );98 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars); 93 99 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 94 100 AddErrors(run, predictedValuesTrain[j++], targetValue); … … 100 106 j = 0; 101 107 foreach (var i in problemData.TestIndices) { 102 var run = CreateRunForIdx(i, problemData );108 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars); 103 109 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 104 110 AddErrors(run, predictedValuesTest[j++], targetValue); … … 127 133 } 128 134 129 private IRun CreateRunForIdx(int i, IRegressionProblemData problemData ) {135 private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars) { 130 136 var ds = problemData.Dataset; 131 137 var run = new Run(); 132 foreach (var variableName in d s.DoubleVariables) {138 foreach (var variableName in doubleVars) { 133 139 run.Results.Add(variableName, new DoubleValue(ds.GetDoubleValue(variableName, i))); 134 140 } 135 foreach (var variableName in ds.StringVariables) {141 foreach (var variableName in stringVars) { 136 142 run.Results.Add(variableName, new StringValue(ds.GetStringValue(variableName, i))); 137 143 } 138 139 144 return run; 140 145 }
Note: See TracChangeset
for help on using the changeset viewer.