Changeset 17808
- Timestamp:
- 12/30/20 09:47:47 (4 years ago)
- Location:
- stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 17341,17539
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views merged: 17341,17539
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4 merged: 17341,17539
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r17181 r17808 88 88 var ds = problemData.Dataset; 89 89 var runs = new RunCollection(); 90 // determine relevant variables (at least two different values)91 var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray();92 var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();93 var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();94 90 95 // produce training and test values separately as they might overlap (e.g. for ensembles) 96 var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray(); 97 int j = 0; // idx for predictedValues array 98 foreach (var i in problemData.TrainingIndices) { 91 var doubleVars = ds.DoubleVariables.ToArray(); 92 var stringVars = ds.StringVariables.ToArray(); 93 var dateTimeVars = ds.DateTimeVariables.ToArray(); 94 95 var predictedValues = Content.EstimatedValues.ToArray(); 96 var targetValues = ds.GetReadOnlyDoubleValues(problemData.TargetVariable); 97 98 foreach (var i in problemData.AllIndices) { 99 99 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars); 100 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 101 AddErrors(run, predictedValuesTrain[j++], targetValue); 102 run.Results.Add(PartitionLabel, new StringValue("Training")); 103 run.Color = Color.Gold; 100 AddErrors(run, predictedValues[i], targetValues[i]); 101 102 if (problemData.IsTrainingSample(i) && problemData.IsTestSample(i)) { 103 run.Results.Add(PartitionLabel, new StringValue("Training + Test")); 104 run.Color = Color.Orange; 105 } else if (problemData.IsTrainingSample(i)) { 106 run.Results.Add(PartitionLabel, new StringValue("Training")); 107 run.Color = Color.Gold; 108 } else if (problemData.IsTestSample(i)) { 109 run.Results.Add(PartitionLabel, new StringValue("Test")); 110 run.Color = Color.Red; 111 } else { 112 run.Results.Add(PartitionLabel, new StringValue("Additional Data")); 113 run.Color = Color.Black; 114 } 104 115 runs.Add(run); 105 116 } 106 var predictedValuesTest = Content.EstimatedTestValues.ToArray(); 107 j = 0; 108 foreach (var i in problemData.TestIndices) { 109 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars); 110 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 111 AddErrors(run, predictedValuesTest[j++], targetValue); 112 run.Results.Add(PartitionLabel, new StringValue("Test")); 113 run.Color = Color.Red; 114 runs.Add(run); 115 } 117 116 118 if (string.IsNullOrEmpty(selectedXAxis)) 117 119 selectedXAxis = "Index"; … … 124 126 } 125 127 126 private void AddErrors(IRun run, double pred, double target) {128 private static void AddErrors(IRun run, double pred, double target) { 127 129 var residual = target - pred; 128 130 var relError = residual / target; … … 135 137 } 136 138 137 private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {139 private static IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) { 138 140 var ds = problemData.Dataset; 139 141 var run = new Run();
Note: See TracChangeset
for help on using the changeset viewer.