Changeset 15810
- Timestamp:
- 02/23/18 17:00:43 (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs
r15583 r15810 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Diagnostics.Contracts;26 25 using System.Linq; 27 26 using HeuristicLab.Algorithms.DataAnalysis; -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
r15789 r15810 164 164 solutionSeries.ChartType = SeriesChartType.FastLine; 165 165 var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution)); 166 residuals.Remove(double.NaN);167 residuals.Remove(double.NegativeInfinity);168 residuals.Remove(double.PositiveInfinity);169 166 170 167 var maxValue = residuals.Max(); … … 252 249 protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) { 253 250 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(); 256 255 case "Relative error": 257 256 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 0259 .ToList();257 .Where(r => r > 0 && !double.IsNaN(r) && !double.IsInfinity(r)) // remove entries where the original value is 0 258 .ToList(); 260 259 default: throw new NotSupportedException(); 261 260 } -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs
r15793 r15810 73 73 74 74 var rows = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(); 75 var targetVa riables = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();76 77 78 this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(rows.ToArray(), targetVa riables.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()); 79 79 // training series 80 80 this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME); … … 164 164 var targetValues = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0); 165 165 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(); 167 168 double interestingValuesRange = Math.Min(Math.Max(targetValuesRange, 1.0), Math.Max(estimatedValuesRange, 1.0)); 168 169 double digits = (int)Math.Log10(interestingValuesRange) - 3; -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs
r15785 r15810 81 81 if (Content != null) { 82 82 List<double> residuals = CalculateResiduals(Content); 83 residuals.Remove(double.NaN);84 residuals.Remove(double.PositiveInfinity);85 residuals.Remove(double.NegativeInfinity);86 83 87 84 double max = 0.0; … … 129 126 130 127 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; 131 130 double residual = estimatedValues[i] - targetValues[i]; 132 131 residuals.Add(residual); -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs
r15787 r15810 38 38 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray(); 39 39 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])) { 41 42 x[i] = target[i] - x[i]; 43 } else { 44 x[i] = 0.0; 42 45 } 43 46 } -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs
r15785 r15810 166 166 this.chart.Series[TEST_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "", 167 167 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(); 170 178 171 179 double axisMin, axisMax, axisInterval; -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisResidualsLineChartView.cs
r15583 r15810 20 20 #endregion 21 21 22 using System;23 22 using System.Linq; 24 using System.Windows.Forms.DataVisualization.Charting;25 23 using HeuristicLab.MainForm; 26 24
Note: See TracChangeset
for help on using the changeset viewer.