Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/15 09:51:05 (9 years ago)
Author:
gkronber
Message:

#2369 merged r12493,r12577,r12642 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r12385 r12668  
    2525using System.Windows.Forms;
    2626using System.Windows.Forms.DataVisualization.Charting;
     27using HeuristicLab.Common;
    2728using HeuristicLab.MainForm;
    2829
     
    4546      cmbSamples.SelectedIndex = 0;
    4647
     48      residualComboBox.SelectedIndex = 0;
     49
    4750      chart.CustomizeAllChartAreas();
    48       chart.ChartAreas[0].AxisX.Title = "Absolute Error";
     51      chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString();
    4952      chart.ChartAreas[0].AxisX.Minimum = 0.0;
    5053      chart.ChartAreas[0].AxisX.Maximum = 0.0;
     
    99102      chart.Series.Clear();
    100103      chart.Annotations.Clear();
     104      chart.ChartAreas[0].AxisX.Maximum = 0.0;
     105      chart.ChartAreas[0].CursorX.Interval = 0.01;
    101106
    102107      if (Content == null) return;
     
    109114
    110115      AddRegressionSolution(Content);
     116
     117      chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString();
    111118    }
    112119
     
    118125      solutionSeries.ChartType = SeriesChartType.FastLine;
    119126      var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    120 
    121127
    122128      var maxValue = residuals.Max();
     
    125131        var maximum = scale * (1 + (int)(maxValue / scale));
    126132        chart.ChartAreas[0].AxisX.Maximum = maximum;
    127       }
    128       chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100;
     133        chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100;
     134      }
    129135
    130136      UpdateSeries(residuals, solutionSeries);
     
    203209
    204210    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    205       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      }
    206219    }
    207220
     
    251264      }
    252265    }
     266
     267    private void residualComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     268      UpdateChart();
     269    }
    253270  }
    254271}
Note: See TracChangeset for help on using the changeset viewer.