Changeset 12969 for branches/gteufl/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/gteufl/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using System.Windows.Forms; 26 26 using System.Windows.Forms.DataVisualization.Charting; 27 using HeuristicLab.Common; 27 28 using HeuristicLab.MainForm; 28 29 … … 45 46 cmbSamples.SelectedIndex = 0; 46 47 48 residualComboBox.SelectedIndex = 0; 49 47 50 chart.CustomizeAllChartAreas(); 48 chart.ChartAreas[0].AxisX.Title = "Absolute Error";51 chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString(); 49 52 chart.ChartAreas[0].AxisX.Minimum = 0.0; 50 chart.ChartAreas[0].AxisX.Maximum = 1.0;53 chart.ChartAreas[0].AxisX.Maximum = 0.0; 51 54 chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; 52 55 chart.ChartAreas[0].CursorX.Interval = 0.01; 53 56 54 chart.ChartAreas[0].AxisY.Title = " Number of Samples";57 chart.ChartAreas[0].AxisY.Title = "Ratio of Residuals"; 55 58 chart.ChartAreas[0].AxisY.Minimum = 0.0; 56 59 chart.ChartAreas[0].AxisY.Maximum = 1.0; … … 99 102 chart.Series.Clear(); 100 103 chart.Annotations.Clear(); 104 chart.ChartAreas[0].AxisX.Maximum = 0.0; 105 chart.ChartAreas[0].CursorX.Interval = 0.01; 106 101 107 if (Content == null) return; 102 103 var constantModel = CreateConstantModel(); 104 var originalValues = GetOriginalValues().ToList(); 105 var baselineEstimatedValues = GetEstimatedValues(constantModel); 106 var baselineResiduals = GetResiduals(originalValues, baselineEstimatedValues); 107 108 baselineResiduals.Sort(); 109 chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(baselineResiduals.Last()); 110 chart.ChartAreas[0].CursorX.Interval = baselineResiduals.First() / 100; 111 112 Series baselineSeries = new Series("Baseline"); 113 baselineSeries.ChartType = SeriesChartType.FastLine; 114 UpdateSeries(baselineResiduals, baselineSeries); 115 baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries); 116 baselineSeries.Tag = constantModel; 117 baselineSeries.LegendToolTip = "Double-click to open model"; 118 chart.Series.Add(baselineSeries); 108 if (cmbSamples.SelectedItem.ToString() == TrainingSamples && !ProblemData.TrainingIndices.Any()) return; 109 if (cmbSamples.SelectedItem.ToString() == TestSamples && !ProblemData.TestIndices.Any()) return; 110 111 if (Content.ProblemData.TrainingIndices.Any()) { 112 AddRegressionSolution(CreateConstantSolution()); 113 } 119 114 120 115 AddRegressionSolution(Content); 116 117 chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString(); 121 118 } 122 119 … … 127 124 solutionSeries.Tag = solution; 128 125 solutionSeries.ChartType = SeriesChartType.FastLine; 129 var estimatedValues = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution)); 130 UpdateSeries(estimatedValues, solutionSeries); 126 var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution)); 127 128 var maxValue = residuals.Max(); 129 if (maxValue >= chart.ChartAreas[0].AxisX.Maximum) { 130 double scale = Math.Pow(10, Math.Floor(Math.Log10(maxValue))); 131 var maximum = scale * (1 + (int)(maxValue / scale)); 132 chart.ChartAreas[0].AxisX.Maximum = maximum; 133 chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100; 134 } 135 136 UpdateSeries(residuals, solutionSeries); 137 131 138 solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries); 132 139 solutionSeries.LegendToolTip = "Double-click to open model"; … … 202 209 203 210 protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) { 204 return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList(); 211 switch (residualComboBox.SelectedItem.ToString()) { 212 case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList(); 213 case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)).ToList(); 214 case "Relative error": return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x)) 215 .Where(x => x > 0) // remove entries where the original value is 0 216 .ToList(); 217 default: throw new NotSupportedException(); 218 } 205 219 } 206 220 … … 233 247 } 234 248 235 private IRegressionSolution CreateConstantModel() {249 private ConstantRegressionSolution CreateConstantSolution() { 236 250 double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average(); 237 251 var model = new ConstantRegressionModel(averageTrainingTarget); 238 var solution = new ConstantRegressionSolution(model, (IRegressionProblemData)ProblemData.Clone());252 var solution = new ConstantRegressionSolution(model, (IRegressionProblemData)ProblemData.Clone()); 239 253 solution.Name = "Baseline"; 240 254 return solution; … … 250 264 } 251 265 } 266 267 private void residualComboBox_SelectedIndexChanged(object sender, EventArgs e) { 268 UpdateChart(); 269 } 252 270 } 253 271 }
Note: See TracChangeset
for help on using the changeset viewer.