Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15810


Ignore:
Timestamp:
02/23/18 17:00:43 (7 years ago)
Author:
gkronber
Message:

#2383: made some changes while reviewing

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r15583 r15810  
    2323using System.Collections;
    2424using System.Collections.Generic;
    25 using System.Diagnostics.Contracts;
    2625using System.Linq;
    2726using HeuristicLab.Algorithms.DataAnalysis;
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r15789 r15810  
    164164      solutionSeries.ChartType = SeriesChartType.FastLine;
    165165      var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    166       residuals.Remove(double.NaN);
    167       residuals.Remove(double.NegativeInfinity);
    168       residuals.Remove(double.PositiveInfinity);
    169166
    170167      var maxValue = residuals.Max();
     
    252249    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    253250      switch (residualComboBox.SelectedItem.ToString()) {
    254         case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList();
    255         case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)).ToList();
     251        case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y))
     252            .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList();
     253        case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y))
     254            .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList();
    256255        case "Relative error":
    257256          return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x))
    258 .Where(x => x > 0) // remove entries where the original value is 0
    259 .ToList();
     257            .Where(r => r > 0 && !double.IsNaN(r) && !double.IsInfinity(r)) // remove entries where the original value is 0
     258            .ToList();
    260259        default: throw new NotSupportedException();
    261260      }
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs

    r15793 r15810  
    7373
    7474        var rows = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray();
    75         var targetVariables = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    76 
    77 
    78         this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(rows.ToArray(), targetVariables.Select(v => double.IsInfinity(v) ? double.NaN : v).ToArray());
     75        var targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable);
     76
     77
     78        this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(rows.ToArray(), targetValues.Select(v => double.IsInfinity(v) ? double.NaN : v).ToArray());
    7979        // training series
    8080        this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME);
     
    164164      var targetValues = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
    165165      double estimatedValuesRange = estimatedValues.Max() - estimatedValues.Min();
    166       double targetValuesRange = targetValues.Where(v => !double.IsInfinity(v) && !double.IsNaN(v)).Max() - targetValues.Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Min();
     166      double targetValuesRange = targetValues.Where(v => !double.IsInfinity(v) && !double.IsNaN(v)).Max() -
     167                                 targetValues.Where(v => !double.IsInfinity(v) && !double.IsNaN(v)).Min();
    167168      double interestingValuesRange = Math.Min(Math.Max(targetValuesRange, 1.0), Math.Max(estimatedValuesRange, 1.0));
    168169      double digits = (int)Math.Log10(interestingValuesRange) - 3;
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs

    r15785 r15810  
    8181      if (Content != null) {
    8282        List<double> residuals = CalculateResiduals(Content);
    83         residuals.Remove(double.NaN);
    84         residuals.Remove(double.PositiveInfinity);
    85         residuals.Remove(double.NegativeInfinity);
    8683
    8784        double max = 0.0;
     
    129126
    130127      for (int i = 0; i < solution.ProblemData.Dataset.Rows; i++) {
     128        if (double.IsNaN(estimatedValues[i]) || double.IsInfinity(estimatedValues[i])) continue;
     129        if (double.IsNaN(targetValues[i]) || double.IsInfinity(targetValues[i])) continue;
    131130        double residual = estimatedValues[i] - targetValues[i];
    132131        residuals.Add(residual);
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs

    r15787 r15810  
    3838      var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray();
    3939      for (int i = 0; i < idx.Length; i++) {
    40         if (!double.IsInfinity(target[i]) && !double.IsNaN(target[i])) {
     40        if (!double.IsInfinity(target[i]) && !double.IsNaN(target[i]) &&
     41            !double.IsInfinity(x[i]) && !double.IsNaN(x[i])) {
    4142          x[i] = target[i] - x[i];
     43        } else {
     44          x[i] = 0.0;
    4245        }
    4346      }
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r15785 r15810  
    166166          this.chart.Series[TEST_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "",
    167167            Content.EstimatedTestValues.ToArray(), "");
    168         double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Where(v => !double.IsInfinity(v)).Max();
    169         double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Where(v => !double.IsNaN(v) && !double.IsNegativeInfinity(v)).Min();
     168        double max = Content.EstimatedTrainingValues
     169          .Concat(Content.EstimatedTestValues
     170          .Concat(Content.EstimatedValues
     171          .Concat(dataset.GetDoubleValues(targetVariableName))))
     172          .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Max();
     173        double min = Content.EstimatedTrainingValues
     174          .Concat(Content.EstimatedTestValues
     175          .Concat(Content.EstimatedValues
     176          .Concat(dataset.GetDoubleValues(targetVariableName))))
     177          .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Min();
    170178
    171179        double axisMin, axisMax, axisInterval;
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisResidualsLineChartView.cs

    r15583 r15810  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    24 using System.Windows.Forms.DataVisualization.Charting;
    2523using HeuristicLab.MainForm;
    2624
Note: See TracChangeset for help on using the changeset viewer.