Changeset 15973 for branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 16 edited
- 20 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 63 63 protected override void SetEnabledStateOfControls() { 64 64 base.SetEnabledStateOfControls(); 65 addButton.Enabled = Content != null && !Content.IsReadOnly && !Locked;66 removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && itemsListView.SelectedItems.Count > 0;65 addButton.Enabled = false; 66 removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && !ReadOnly && itemsListView.SelectedItems.Count > 0; 67 67 itemsListView.Enabled = Content != null && !Locked; 68 68 detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1; 69 sortAscendingButton.Enabled = false; 70 sortDescendingButton.Enabled = false; 69 71 } 72 73 //forbid sorting 74 protected override void SortItemsListView(SortOrder sortOrder) { } 70 75 71 76 protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionFeatureCorrelationView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionFeatureCorrelationView.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs
r13002 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
r13100 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 154 154 } 155 155 156 chart.ChartAreas[0].AxisX.Title = residualComboBox.SelectedItem.ToString();156 chart.ChartAreas[0].AxisX.Title = string.Format("{0} ({1})", residualComboBox.SelectedItem, Content.ProblemData.TargetVariable); 157 157 } 158 158 … … 249 249 protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) { 250 250 switch (residualComboBox.SelectedItem.ToString()) { 251 case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList(); 252 case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)).ToList(); 253 case "Relative error": return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x)) 254 .Where(x => x > 0) // remove entries where the original value is 0 255 .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(); 255 case "Relative error": 256 return originalValues.Zip(estimatedValues, (x, y) => x.IsAlmost(0.0) ? -1 : Math.Abs((x - y) / x)) 257 .Where(r => r > 0 && !double.IsNaN(r) && !double.IsInfinity(r)) // remove entries where the original value is 0 258 .ToList(); 256 259 default: throw new NotSupportedException(); 257 260 } … … 292 295 private IRegressionSolution CreateConstantSolution() { 293 296 double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average(); 294 var model = new ConstantModel(averageTrainingTarget );297 var model = new ConstantModel(averageTrainingTarget, ProblemData.TargetVariable); 295 298 var solution = model.CreateRegressionSolution(ProblemData); 296 299 solution.Name = "Baseline (constant)"; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using HeuristicLab.Data.Views; 26 26 using HeuristicLab.MainForm; 27 using HeuristicLab.MainForm.WindowsForms;28 27 29 28 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 68 67 } 69 68 70 pr ivatevoid Content_ProblemDataChanged(object sender, EventArgs e) {69 protected virtual void Content_ProblemDataChanged(object sender, EventArgs e) { 71 70 OnContentChanged(); 72 71 } 73 72 74 pr ivatevoid Content_ModelChanged(object sender, EventArgs e) {73 protected virtual void Content_ModelChanged(object sender, EventArgs e) { 75 74 OnContentChanged(); 76 75 } … … 81 80 } 82 81 83 private void UpdateEstimatedValues() { 82 protected virtual StringMatrix CreateValueMatrix() { 83 string[,] values = new string[Content.ProblemData.Dataset.Rows, 8]; 84 85 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 86 var estimated = Content.EstimatedValues.GetEnumerator(); 87 var estimated_training = Content.EstimatedTrainingValues.GetEnumerator(); 88 var estimated_test = Content.EstimatedTestValues.GetEnumerator(); 89 90 foreach (var row in Content.ProblemData.TrainingIndices) { 91 estimated_training.MoveNext(); 92 values[row, 3] = estimated_training.Current.ToString(); 93 } 94 95 foreach (var row in Content.ProblemData.TestIndices) { 96 estimated_test.MoveNext(); 97 values[row, 4] = estimated_test.Current.ToString(); 98 } 99 100 foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) { 101 estimated.MoveNext(); 102 double est = estimated.Current; 103 double res = target[row] - est; 104 values[row, 0] = row.ToString(); 105 values[row, 1] = target[row].ToString(); 106 values[row, 2] = est.ToString(); 107 values[row, 5] = res.ToString(); 108 values[row, 6] = Math.Abs(res).ToString(); 109 values[row, 7] = Math.Abs(res / target[row]).ToString(); 110 } 111 112 var matrix = new StringMatrix(values); 113 matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Residuals (all)", "Absolute Error (all)", "Relative Error (all)" }; 114 matrix.SortableView = true; 115 return matrix; 116 } 117 118 protected virtual void UpdateEstimatedValues() { 84 119 if (InvokeRequired) Invoke((Action)UpdateEstimatedValues); 85 120 else { 86 121 StringMatrix matrix = null; 87 122 if (Content != null) { 88 string[,] values = new string[Content.ProblemData.Dataset.Rows, 7]; 89 90 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 91 var estimated = Content.EstimatedValues.GetEnumerator(); 92 var estimated_training = Content.EstimatedTrainingValues.GetEnumerator(); 93 var estimated_test = Content.EstimatedTestValues.GetEnumerator(); 94 95 foreach (var row in Content.ProblemData.TrainingIndices) { 96 estimated_training.MoveNext(); 97 values[row, 3] = estimated_training.Current.ToString(); 98 } 99 100 foreach (var row in Content.ProblemData.TestIndices) { 101 estimated_test.MoveNext(); 102 values[row, 4] = estimated_test.Current.ToString(); 103 } 104 105 foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) { 106 estimated.MoveNext(); 107 double est = estimated.Current; 108 double res = Math.Abs(est - target[row]); 109 values[row, 0] = row.ToString(); 110 values[row, 1] = target[row].ToString(); 111 values[row, 2] = est.ToString(); 112 values[row, 5] = Math.Abs(res).ToString(); 113 values[row, 6] = Math.Abs(res / target[row]).ToString(); 114 } 115 116 matrix = new StringMatrix(values); 117 matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)" }; 118 matrix.SortableView = true; 123 matrix = CreateValueMatrix(); 119 124 } 120 125 matrixView.Content = matrix; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs
r15674 r15973 20 20 #endregion 21 21 using System; 22 using System.Collections.Generic;23 22 using System.Drawing; 24 23 using System.Linq; … … 72 71 this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = TARGETVARIABLE_SERIES_NAME; 73 72 this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine; 74 this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(), 75 Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray()); 73 74 var rows = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).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()); 76 79 // training series 77 80 this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME); … … 161 164 var targetValues = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0); 162 165 double estimatedValuesRange = estimatedValues.Max() - estimatedValues.Min(); 163 double targetValuesRange = targetValues.Max() - targetValues.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(); 164 168 double interestingValuesRange = Math.Min(Math.Max(targetValuesRange, 1.0), Math.Max(estimatedValuesRange, 1.0)); 165 169 double digits = (int)Math.Log10(interestingValuesRange) - 3; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r15674 r15973 89 89 var runs = new RunCollection(); 90 90 // determine relevant variables (at least two different values) 91 var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn). Max() > ds.GetDoubleValues(vn).Min()).ToArray();91 var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray(); 92 92 var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray(); 93 93 var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray(); -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 96 96 97 97 ChartArea chartArea = chart.ChartAreas[0]; 98 chartArea.AxisX.Title = string.Format("Residuals ({0})", Content.ProblemData.TargetVariable); 98 99 chartArea.AxisX.Minimum = -roundedMax - intervalWidth; 99 100 chartArea.AxisX.Maximum = roundedMax + intervalWidth; … … 125 126 126 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; 127 130 double residual = estimatedValues[i] - targetValues[i]; 128 131 residuals.Add(residual); -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs
r15674 r15973 38 38 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray(); 39 39 for (int i = 0; i < idx.Length; i++) { 40 x[i] = target[i] - x[i]; 40 if (!double.IsInfinity(target[i]) && !double.IsNaN(target[i]) && 41 !double.IsInfinity(x[i]) && !double.IsNaN(x[i])) { 42 x[i] = target[i] - x[i]; 43 } else { 44 x[i] = 0.0; 45 } 41 46 } 42 47 } -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs
r12509 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using HeuristicLab.MainForm; 27 27 using HeuristicLab.MainForm.WindowsForms; 28 using HeuristicLab.Visualization.ChartControlsExtensions; 28 29 29 30 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 35 36 private const string TEST_SERIES = "Test samples"; 36 37 38 private const int OPACITY_LEVEL = 150; 39 37 40 public new IRegressionSolution Content { 38 41 get { return (IRegressionSolution)base.Content; } … … 60 63 this.chart.AxisViewChanged += new EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(chart_AxisViewChanged); 61 64 65 //make series colors semi transparent 66 this.chart.ApplyPaletteColors(); 67 this.chart.Series[ALL_SERIES].Color = Color.FromArgb(OPACITY_LEVEL, this.chart.Series[ALL_SERIES].Color); 68 this.chart.Series[TRAINING_SERIES].Color = Color.FromArgb(OPACITY_LEVEL, this.chart.Series[TRAINING_SERIES].Color); 69 this.chart.Series[TEST_SERIES].Color = Color.FromArgb(OPACITY_LEVEL, this.chart.Series[TEST_SERIES].Color); 70 71 //change all markers to circles 72 this.chart.Series[ALL_SERIES].MarkerStyle = MarkerStyle.Circle; 73 this.chart.Series[TRAINING_SERIES].MarkerStyle = MarkerStyle.Circle; 74 this.chart.Series[TEST_SERIES].MarkerStyle = MarkerStyle.Circle; 75 62 76 //configure axis 63 77 this.chart.CustomizeAllChartAreas(); 64 this.chart.ChartAreas[0].AxisX.Title = "Estimated Values"; 78 this.chart.ChartAreas[0].AxisY.Title = "Estimated Values"; 79 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; 80 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; 81 this.chart.ChartAreas[0].CursorX.Interval = 1; 82 this.chart.ChartAreas[0].CursorY.Interval = 1; 83 84 this.chart.ChartAreas[0].AxisX.Title = "Target Values"; 65 85 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; 66 86 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; 67 this.chart.ChartAreas[0].CursorX.Interval = 1; 68 this.chart.ChartAreas[0].CursorY.Interval = 1; 69 70 this.chart.ChartAreas[0].AxisY.Title = "Target Values"; 71 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; 72 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; 73 this.chart.ChartAreas[0].AxisY.IsStartedFromZero = true; 87 this.chart.ChartAreas[0].AxisX.IsStartedFromZero = true; 74 88 } 75 89 … … 144 158 var dataset = Content.ProblemData.Dataset; 145 159 if (this.chart.Series[ALL_SERIES].Points.Count > 0) 146 this.chart.Series[ALL_SERIES].Points.DataBindXY( Content.EstimatedValues.ToArray(), "",147 dataset.GetDoubleValues(targetVariableName).ToArray(), "");160 this.chart.Series[ALL_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName).ToArray(), "", 161 Content.EstimatedValues.ToArray(), ""); 148 162 if (this.chart.Series[TRAINING_SERIES].Points.Count > 0) 149 this.chart.Series[TRAINING_SERIES].Points.DataBindXY( Content.EstimatedTrainingValues.ToArray(), "",150 dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndices).ToArray(), "");163 this.chart.Series[TRAINING_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndices).ToArray(), "", 164 Content.EstimatedTrainingValues.ToArray(), ""); 151 165 if (this.chart.Series[TEST_SERIES].Points.Count > 0) 152 this.chart.Series[TEST_SERIES].Points.DataBindXY(Content.EstimatedTestValues.ToArray(), "", 153 dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), ""); 154 155 double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Max(); 156 double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Min(); 157 158 max = max + 0.2 * Math.Abs(max); 159 min = min - 0.2 * Math.Abs(min); 160 161 double interestingValuesRange = max - min; 162 int digits = Math.Max(0, 3 - (int)Math.Log10(interestingValuesRange)); 163 164 max = Math.Round(max, digits); 165 min = Math.Round(min, digits); 166 167 this.chart.ChartAreas[0].AxisX.Maximum = max; 168 this.chart.ChartAreas[0].AxisX.Minimum = min; 169 this.chart.ChartAreas[0].AxisY.Maximum = max; 170 this.chart.ChartAreas[0].AxisY.Minimum = min; 166 this.chart.Series[TEST_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "", 167 Content.EstimatedTestValues.ToArray(), ""); 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(); 178 179 double axisMin, axisMax, axisInterval; 180 ChartUtil.CalculateOptimalAxisInterval(min, max, out axisMin, out axisMax, out axisInterval); 181 this.chart.ChartAreas[0].AxisY.Title = "Estimated " + targetVariableName; 182 this.chart.ChartAreas[0].AxisY.Maximum = axisMax; 183 this.chart.ChartAreas[0].AxisY.Minimum = axisMin; 184 this.chart.ChartAreas[0].AxisY.Interval = axisInterval; 185 this.chart.ChartAreas[0].AxisX.Title = targetVariableName; 186 this.chart.ChartAreas[0].AxisX.Maximum = axisMax; 187 this.chart.ChartAreas[0].AxisX.Minimum = axisMin; 188 this.chart.ChartAreas[0].AxisX.Interval = axisInterval; 189 171 190 UpdateCursorInterval(); 172 191 } … … 204 223 } 205 224 if (predictedValues.Length == targetValues.Length) 206 series.Points.DataBindXY( predictedValues, "", targetValues, "");225 series.Points.DataBindXY(targetValues, "", predictedValues, ""); 207 226 this.chart.Legends[series.Legend].ForeColor = Color.Black; 208 227 UpdateCursorInterval(); -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15674 r15973 186 186 this.Name = "RegressionSolutionVariableImpactsView"; 187 187 this.Size = new System.Drawing.Size(712, 365); 188 this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged); 188 189 this.ResumeLayout(false); 189 190 this.PerformLayout(); -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r15674 r15973 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using System.Threading.Tasks; 26 27 using HeuristicLab.Common; … … 32 33 [Content(typeof(IRegressionSolution))] 33 34 public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 35 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 34 36 private enum SortingCriteria { 35 37 ImpactValue, … … 37 39 VariableName 38 40 } 39 41 private IProgress progress; 40 42 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 41 43 … … 55 57 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 56 58 59 //Set the default values 57 60 this.dataPartitionComboBox.SelectedIndex = 0; 58 61 this.replacementComboBox.SelectedIndex = 0; … … 60 63 } 61 64 62 #region events63 65 protected override void RegisterContentEvents() { 64 66 base.RegisterContentEvents(); … … 86 88 variableImactsArrayView.Content = null; 87 89 } else { 88 UpdateVariableImpacts(); 90 UpdateVariableImpact(); 91 } 92 } 93 94 private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 95 if (!cancellationToken.IsCancellationRequested) { 96 cancellationToken.Cancel(); 89 97 } 90 98 } … … 92 100 93 101 private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) { 94 UpdateVariableImpact s();102 UpdateVariableImpact(); 95 103 } 96 104 97 105 private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) { 98 UpdateVariableImpact s();106 UpdateVariableImpact(); 99 107 } 100 108 … … 123 131 UpdateDataOrdering(); 124 132 } 125 #endregion 126 127 #region Helper Methods128 private void UpdateVariableImpacts() {133 134 135 private async void UpdateVariableImpact() { 136 //Check if the selection is valid 129 137 if (Content == null) { return; } 130 138 if (replacementComboBox.SelectedIndex < 0) { return; } … … 132 140 if (factorVarReplComboBox.SelectedIndex < 0) { return; } 133 141 134 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 135 142 //Prepare arguments 136 143 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm; 137 144 var replMethod = (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex]; … … 139 146 var dataPartition = (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 140 147 141 Task.Factory.StartNew(() => { 142 try { 143 mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name); 144 145 //Remember the original ordering of the variables 146 var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod); 147 var problemData = Content.ProblemData; 148 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 149 var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList(); 150 rawVariableImpacts.Clear(); 151 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 152 UpdateDataOrdering(); 153 } finally { 154 mainForm.RemoveOperationProgressFromView(this); 155 } 156 }); 148 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 149 progress = mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name); 150 progress.ProgressValue = 0; 151 152 cancellationToken = new CancellationTokenSource(); 153 //Remember the original ordering of the variables 154 try { 155 var impacts = await Task.Run(() => RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod, 156 (i, s) => { 157 progress.ProgressValue = i; 158 progress.Status = s; 159 return cancellationToken.Token.IsCancellationRequested; 160 }), cancellationToken.Token); 161 162 if (cancellationToken.Token.IsCancellationRequested) { return; } 163 var problemData = Content.ProblemData; 164 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 165 var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList(); 166 167 rawVariableImpacts.Clear(); 168 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 169 UpdateDataOrdering(); 170 } finally { 171 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this); 172 } 157 173 } 158 174 … … 193 209 ElementNames = orderedEntries.Select(i => i.Key) 194 210 }; 195 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 196 } 197 #endregion 211 212 //Could be, if the View was closed 213 if (!variableImactsArrayView.IsDisposed) { 214 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 215 } 216 } 198 217 } 199 218 } -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionTimeframeFeatureCorrelationView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionTimeframeFeatureCorrelationView.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.