Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/25/15 11:26:25 (9 years ago)
Author:
mkommend
Message:

#2276: Merged trunk changes into dataset refactoring branch.

Location:
branches/HeuristicLab.DatasetRefactor/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatasetRefactor/sources

  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis.Views

  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r12438 r12505  
    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;
     
    109112
    110113      AddRegressionSolution(Content);
     114
     115      chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString();
    111116    }
    112117
     
    119124      var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    120125
    121 
    122126      var maxValue = residuals.Max();
    123       if (maxValue >= chart.ChartAreas[0].AxisX.Maximum) {
    124         double scale = Math.Pow(10, Math.Floor(Math.Log10(maxValue)));
    125         var maximum = scale * (1 + (int)(maxValue / scale));
    126         chart.ChartAreas[0].AxisX.Maximum = maximum;
    127       }
     127      double scale = Math.Pow(10, Math.Floor(Math.Log10(maxValue)));
     128      var maximum = scale * (1 + (int)(maxValue / scale));
     129      chart.ChartAreas[0].AxisX.Maximum = maximum;
    128130      chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100;
    129131
     
    203205
    204206    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    205       return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList();
     207      switch (residualComboBox.SelectedItem.ToString()) {
     208        case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList();
     209        case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)).ToList();
     210        case "Relative error": return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x))
     211          .Where(x => x > 0) // remove entries where the original value is 0
     212          .ToList();
     213      }
     214      // should never happen
     215      return new List<double>();
    206216    }
    207217
     
    251261      }
    252262    }
     263
     264    private void residualComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     265      UpdateChart();
     266    }
    253267  }
    254268}
Note: See TracChangeset for help on using the changeset viewer.