- Timestamp:
- 09/16/11 12:00:36 (13 years ago)
- Location:
- branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.Designer.cs
r6675 r6784 44 44 /// </summary> 45 45 private void InitializeComponent() { 46 this.problemView1 = new HeuristicLab.Optimization.Views.ProblemView();47 46 this.SamplesComboBox = new System.Windows.Forms.ComboBox(); 48 47 this.SuspendLayout(); … … 56 55 this.matrixView.Location = new System.Drawing.Point(3, 31); 57 56 this.matrixView.Size = new System.Drawing.Size(304, 251); 58 //59 // problemView160 //61 this.problemView1.Caption = "Problem View";62 this.problemView1.Content = null;63 this.problemView1.Location = new System.Drawing.Point(1147, 687);64 this.problemView1.Name = "problemView1";65 this.problemView1.ReadOnly = false;66 this.problemView1.Size = new System.Drawing.Size(490, 353);67 this.problemView1.TabIndex = 1;68 57 // 69 58 // SamplesComboBox … … 84 73 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 85 74 this.Controls.Add(this.SamplesComboBox); 86 this.Controls.Add(this.problemView1);87 75 this.Name = "ClassificationEnsembleSolutionEstimatedClassValuesView"; 88 76 this.Controls.SetChildIndex(this.matrixView, 0); 89 this.Controls.SetChildIndex(this.problemView1, 0);90 77 this.Controls.SetChildIndex(this.SamplesComboBox, 0); 91 78 this.ResumeLayout(false); … … 95 82 #endregion 96 83 97 private Optimization.Views.ProblemView problemView1;98 84 private System.Windows.Forms.ComboBox SamplesComboBox; 99 85 -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs
r6675 r6784 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Drawing; 23 24 using System.Linq; 24 25 using System.Windows.Forms; … … 33 34 ClassificationSolutionEstimatedClassValuesView { 34 35 private const string RowColumnName = "Row"; 35 private const string TargetClassValuesColumnName = "TargetVariable"; 36 private const string EstimatedClassValuesColumnName = "EstimatedClassValues"; 36 private const string TargetClassValuesColumnName = "Target Variable"; 37 private const string EstimatedClassValuesColumnName = "Estimated Class Values"; 38 private const string CorrectClassificationColumnName = "Correct Classification"; 37 39 private const string ConfidenceColumnName = "Confidence"; 38 40 … … 51 53 SamplesComboBox.Items.AddRange(new string[] { SamplesComboBoxAllSamples, SamplesComboBoxTrainingSamples, SamplesComboBoxTestSamples }); 52 54 SamplesComboBox.SelectedIndex = 0; 55 matrixView.DataGridView.RowPrePaint += new DataGridViewRowPrePaintEventHandler(DataGridView_RowPrePaint); 53 56 } 57 58 54 59 55 60 private void SamplesComboBox_SelectedIndexChanged(object sender, EventArgs e) { … … 92 97 int classValuesCount = Content.ProblemData.ClassValues.Count; 93 98 int modelCount = Content.Model.Models.Count(); 94 string[,] values = new string[indizes.Length, 4+ classValuesCount + modelCount];95 double[] target = Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.TargetVariable);99 string[,] values = new string[indizes.Length, 5 + classValuesCount + modelCount]; 100 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 96 101 List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indizes, 97 102 Content.ClassificationSolutions); … … 102 107 values[i, 1] = target[i].ToString(); 103 108 values[i, 2] = estimatedClassValues[i].ToString(); 109 values[i, 3] = (target[i] == estimatedClassValues[i]).ToString(); 104 110 var groups = estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); 105 111 var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum(); 106 values[i, 3] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();112 values[i, 4] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString(); 107 113 for (int classIndex = 0; classIndex < Content.ProblemData.ClassValues.Count; classIndex++) { 108 114 var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues[classIndex]).SingleOrDefault(); 109 if (group == null) values[i, 4+ classIndex] = 0.ToString();110 else values[i, 4+ classIndex] = group.Count.ToString();115 if (group == null) values[i, 5 + classIndex] = 0.ToString(); 116 else values[i, 5 + classIndex] = group.Count.ToString(); 111 117 } 112 118 for (int modelIndex = 0; modelIndex < estimatedValuesVector[i].Count; modelIndex++) { 113 values[i, 4+ classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null119 values[i, 5 + classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null 114 120 ? string.Empty 115 121 : estimatedValuesVector[i][modelIndex].ToString(); … … 119 125 120 126 StringMatrix matrix = new StringMatrix(values); 121 List<string> columnNames = new List<string>() { "Id", TargetClassValuesColumnName, EstimatedClassValuesColumnName, Co nfidenceColumnName };127 List<string> columnNames = new List<string>() { "Id", TargetClassValuesColumnName, EstimatedClassValuesColumnName, CorrectClassificationColumnName, ConfidenceColumnName }; 122 128 columnNames.AddRange(Content.ProblemData.ClassNames); 123 129 columnNames.AddRange(Content.Model.Models.Select(m => m.Name)); … … 125 131 matrix.SortableView = true; 126 132 matrixView.Content = matrix; 133 UpdateColoringOfRows(); 127 134 } 128 135 … … 150 157 } 151 158 159 private void DataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { 160 if (InvokeRequired) { 161 Invoke(new EventHandler<DataGridViewRowPrePaintEventArgs>(DataGridView_RowPrePaint), sender, e); 162 return; 163 } 164 bool correctClassified = bool.Parse(matrixView.DataGridView[3, e.RowIndex].Value.ToString()); 165 matrixView.DataGridView.Rows[e.RowIndex].DefaultCellStyle.ForeColor = correctClassified ? Color.MediumSeaGreen : Color.Red; 166 } 152 167 153 168 private void UpdateColoringOfRows() { 169 if (InvokeRequired) { 170 Invoke((Action)UpdateColoringOfRows); 171 return; 172 } 173 //matrixView.DataGridView.SuspendRepaint(); 174 //for (int i = 0; i < matrixView.DataGridView.Rows.Count; i++) { 175 // bool correctClassified = bool.Parse(matrixView.Content.GetValue(i, 3)); 176 // matrixView.DataGridView.Rows[i].DefaultCellStyle.ForeColor = correctClassified ? Color.MediumSeaGreen : Color.Red; 177 //} 178 //matrixView.DataGridView.ResumeRepaint(true); 179 } 154 180 } 155 181 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs
r6647 r6784 114 114 } else throw new InvalidOperationException(); 115 115 116 double[] targetValues = Content.ProblemData.Dataset.Get EnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();116 double[] targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, rows).ToArray(); 117 117 118 118 Dictionary<double, int> classValueIndexMapping = new Dictionary<double, int>(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionEstimatedClassValuesView.cs
r6647 r6784 86 86 string[,] values = new string[Content.ProblemData.Dataset.Rows, 5]; 87 87 88 double[] target = Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.TargetVariable);88 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 89 89 double[] estimated = Content.EstimatedClassValues.ToArray(); 90 90 for (int row = 0; row < target.Length; row++) { -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs
r6647 r6784 107 107 108 108 double[] estimatedValues = Content.GetEstimatedValues(rows).ToArray(); 109 double[] targetClassValues = Content.ProblemData.Dataset.Get EnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();109 double[] targetClassValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, rows).ToArray(); 110 110 double minThreshold = estimatedValues.Min(); 111 111 double maxThreshold = estimatedValues.Max(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionEstimatedClassValuesView.cs
r6647 r6784 51 51 string[,] values = new string[Content.ProblemData.Dataset.Rows, 4]; 52 52 53 double[] target = Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.TargetVariable);53 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 54 54 double[] estimatedClassValues = Content.EstimatedClassValues.ToArray(); 55 55 double[] estimatedValues = Content.EstimatedValues.ToArray(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.cs
r6647 r6784 32 32 namespace HeuristicLab.Problems.DataAnalysis.Views { 33 33 [View("Classification Threshold")] 34 [Content(typeof(IDiscriminantFunctionClassificationSolution), true)]34 [Content(typeof(IDiscriminantFunctionClassificationSolution), false)] 35 35 public sealed partial class DiscriminantFunctionClassificationSolutionThresholdView : DataAnalysisSolutionEvaluationView { 36 36 private const double TrainingAxisValue = 0.0; … … 135 135 private void FillSeriesWithDataPoints(Series series) { 136 136 List<double> estimatedValues = Content.EstimatedValues.ToList(); 137 var targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToList(); 138 137 139 foreach (int row in Content.ProblemData.TrainingIndizes) { 138 140 double estimatedValue = estimatedValues[row]; 139 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable,row];141 double targetValue = targetValues[row]; 140 142 if (targetValue.IsAlmost((double)series.Tag)) { 141 143 double jitterValue = random.NextDouble() * 2.0 - 1.0; … … 150 152 foreach (int row in Content.ProblemData.TestIndizes) { 151 153 double estimatedValue = estimatedValues[row]; 152 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable,row];153 if (targetValue == (double)series.Tag) {154 double targetValue = targetValues[row]; 155 if (targetValue.IsAlmost((double)series.Tag)) { 154 156 double jitterValue = random.NextDouble() * 2.0 - 1.0; 155 157 DataPoint point = new DataPoint(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionEstimatedClusterView.cs
r6647 r6784 85 85 int[] clusters = Content.Model.GetClusterValues(Content.ProblemData.Dataset, Enumerable.Range(0, Content.ProblemData.Dataset.Rows)).ToArray(); 86 86 var dataset = Content.ProblemData.Dataset; 87 int columns = Content.ProblemData.AllowedInputVariables.Count() + 1; 88 var columnsIndixes = Content.ProblemData.AllowedInputVariables.Select(x => dataset.GetVariableIndex(x)).ToList(); 87 int columns = Content.ProblemData.AllowedInputVariables.Count() + 1; 89 88 90 89 double[,] values = new double[dataset.Rows, columns]; … … 93 92 94 93 int column = 1; 95 foreach ( int columnIndex in columnsIndixes) {96 values[row, column] = dataset [row, columnIndex];94 foreach (var columnName in Content.ProblemData.AllowedInputVariables) { 95 values[row, column] = dataset.GetDoubleValue(columnName, row); 97 96 column++; 98 97 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
r6647 r6784 139 139 if (residuals[i] > chart.ChartAreas[0].AxisX.Maximum) { 140 140 point.XValue = chart.ChartAreas[0].AxisX.Maximum; 141 point.YValues[0] = ((double)i - 1) / residuals.Count;141 point.YValues[0] = ((double)i) / residuals.Count; 142 142 point.ToolTip = "Error: " + point.XValue + "\n" + "Samples: " + point.YValues[0]; 143 143 series.Points.Add(point); … … 146 146 147 147 point.XValue = residuals[i]; 148 point.YValues[0] = ((double)i ) / residuals.Count;148 point.YValues[0] = ((double)i+1) / residuals.Count; 149 149 point.ToolTip = "Error: " + point.XValue + "\n" + "Samples: " + point.YValues[0]; 150 150 series.Points.Add(point); … … 164 164 switch (cmbSamples.SelectedItem.ToString()) { 165 165 case TrainingSamples: 166 originalValues = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);166 originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); 167 167 break; 168 168 case TestSamples: 169 originalValues = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes);169 originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndizes); 170 170 break; 171 171 case AllSamples: 172 originalValues = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.TargetVariable);172 originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable); 173 173 break; 174 174 default: … … 197 197 198 198 protected IEnumerable<double> GetMeanModelEstimatedValues(IEnumerable<double> originalValues) { 199 double averageTrainingTarget = ProblemData.Dataset.Get EnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();199 double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average(); 200 200 return Enumerable.Repeat(averageTrainingTarget, originalValues.Count()); 201 201 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs
r6647 r6784 88 88 string[,] values = new string[Content.ProblemData.Dataset.Rows, 7]; 89 89 90 double[] target = Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.TargetVariable);90 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 91 91 var estimated = Content.EstimatedValues.GetEnumerator(); 92 92 var estimated_training = Content.EstimatedTrainingValues.GetEnumerator(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs
r5809 r6784 63 63 this.chart.Size = new System.Drawing.Size(358, 225); 64 64 this.chart.TabIndex = 0; 65 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 65 66 this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Chart_MouseDoubleClick); 67 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 68 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 66 69 // 67 // LineChartView70 // RegressionSolutionLineChartView 68 71 // 69 72 this.AllowDrop = true; … … 71 74 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 72 75 this.Controls.Add(this.chart); 73 this.Name = " LineChartView";76 this.Name = "RegressionSolutionLineChartView"; 74 77 this.Size = new System.Drawing.Size(358, 225); 75 78 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
r6647 r6784 20 20 #endregion 21 21 using System; 22 using System.Collections.Generic; 22 23 using System.Drawing; 23 24 using System.Linq; … … 34 35 private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)"; 35 36 private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Values (test)"; 37 private const string ESTIMATEDVALUES_ALL_SERIES_NAME = "Estimated Values (all samples)"; 36 38 37 39 public new IRegressionSolution Content { … … 65 67 this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine; 66 68 this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(), 67 Content.ProblemData.Dataset.Get VariableValues(Content.ProblemData.TargetVariable));69 Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray()); 68 70 69 71 this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME); 70 72 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME; 71 73 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine; 72 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), 73 Content.EstimatedTrainingValues.ToArray()); 74 this.chart.DataManipulator.InsertEmptyPoints(Content.ProblemData.Dataset.Rows, IntervalType.Number, ESTIMATEDVALUES_TRAINING_SERIES_NAME); 74 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray()); 75 75 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content; 76 this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, ESTIMATEDVALUES_TRAINING_SERIES_NAME); 77 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0; 78 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None; 79 76 80 77 81 this.chart.Series.Add(ESTIMATEDVALUES_TEST_SERIES_NAME); 78 82 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME; 79 83 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine; 80 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), 81 Content.EstimatedTestValues.ToArray()); 84 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray()); 82 85 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content; 86 87 88 int[] allIndizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray(); 89 var estimatedValues = Content.EstimatedValues.ToArray(); 90 List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList(); 91 92 this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME); 93 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME; 94 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine; 95 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues); 96 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content; 97 this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, ESTIMATEDVALUES_ALL_SERIES_NAME); 98 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0; 99 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None; 100 this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]); 101 83 102 UpdateCursorInterval(); 84 103 this.UpdateStripLines(); … … 109 128 } 110 129 111 private void Content_ProblemDataChanged(object sender, EventArgs e) {112 RedrawChart();113 }114 115 private void Content_ModelChanged(object sender, EventArgs e) {116 UpdateEstimatedValuesLineChart();117 }118 119 130 protected override void OnContentChanged() { 120 131 base.OnContentChanged(); 121 132 RedrawChart(); 122 133 } 123 124 private void UpdateEstimatedValuesLineChart() { 125 if (InvokeRequired) Invoke((Action)UpdateEstimatedValuesLineChart); 126 else { 127 if (this.chart.Series.Count > 0) { 128 Series s = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME]; 129 if (s != null) { 130 s.Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray()); 131 s.LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME; 132 } 133 s = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME]; 134 if (s != null) { 135 s.Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray()); 136 s.LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME; 137 } 138 this.UpdateStripLines(); 139 UpdateCursorInterval(); 140 } 141 } 142 } 134 private void Content_ProblemDataChanged(object sender, EventArgs e) { 135 RedrawChart(); 136 } 137 private void Content_ModelChanged(object sender, EventArgs e) { 138 RedrawChart(); 139 } 140 141 143 142 144 143 private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) { … … 201 200 this.chart.ChartAreas[0].AxisX.StripLines.Add(stripLine); 202 201 } 202 203 private void ToggleSeriesData(Series series) { 204 if (series.Points.Count > 0) { //checks if series is shown 205 if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) { 206 series.Points.Clear(); 207 } 208 } else if (Content != null) { 209 string targetVariableName = Content.ProblemData.TargetVariable; 210 211 IEnumerable<int> indizes = null; 212 IEnumerable<double> predictedValues = null; 213 switch (series.Name) { 214 case ESTIMATEDVALUES_ALL_SERIES_NAME: 215 indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray(); 216 var estimatedValues = Content.EstimatedValues.ToArray(); 217 predictedValues = indizes.Select(index => estimatedValues[index]).ToList(); 218 break; 219 case ESTIMATEDVALUES_TRAINING_SERIES_NAME: 220 indizes = Content.ProblemData.TrainingIndizes.ToArray(); 221 predictedValues = Content.EstimatedTrainingValues.ToArray(); 222 break; 223 case ESTIMATEDVALUES_TEST_SERIES_NAME: 224 indizes = Content.ProblemData.TestIndizes.ToArray(); 225 predictedValues = Content.EstimatedTestValues.ToArray(); 226 break; 227 } 228 series.Points.DataBindXY(indizes, predictedValues); 229 chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, series.Name); 230 chart.Legends[series.Legend].ForeColor = Color.Black; 231 UpdateCursorInterval(); 232 chart.Refresh(); 233 } 234 } 235 236 private void chart_MouseMove(object sender, MouseEventArgs e) { 237 HitTestResult result = chart.HitTest(e.X, e.Y); 238 if (result.ChartElementType == ChartElementType.LegendItem && result.Series.Name != TARGETVARIABLE_SERIES_NAME) 239 Cursor = Cursors.Hand; 240 else 241 Cursor = Cursors.Default; 242 } 243 private void chart_MouseDown(object sender, MouseEventArgs e) { 244 HitTestResult result = chart.HitTest(e.X, e.Y); 245 if (result.ChartElementType == ChartElementType.LegendItem && result.Series.Name != TARGETVARIABLE_SERIES_NAME) { 246 ToggleSeriesData(result.Series); 247 } 248 } 249 250 private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) { 251 if (chart.Series.Count != 4) return; 252 e.LegendItems[0].Cells[1].ForeColor = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 253 e.LegendItems[1].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 254 e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 255 e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 256 } 203 257 } 204 258 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.Designer.cs
r5809 r6784 64 64 this.chart.Size = new System.Drawing.Size(527, 392); 65 65 this.chart.TabIndex = 1; 66 this.chart.PostPaint += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs>(this.chart_PostPaint); 67 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 68 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 66 69 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 67 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);68 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(chart_CustomizeLegend);69 70 // 70 // ScatterPlotView71 // RegressionSolutionScatterPlotView 71 72 // 73 this.AllowDrop = true; 72 74 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 73 75 this.Controls.Add(this.chart); 74 this.Name = "ScatterPlotView"; 75 this.AllowDrop = true; 76 this.Name = "RegressionSolutionScatterPlotView"; 76 77 this.Size = new System.Drawing.Size(527, 392); 77 78 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs
r6647 r6784 130 130 if (this.chart.Series[ALL_SERIES].Points.Count > 0) 131 131 this.chart.Series[ALL_SERIES].Points.DataBindXY(Content.EstimatedValues.ToArray(), "", 132 dataset.Get VariableValues(targetVariableName), "");132 dataset.GetDoubleValues(targetVariableName).ToArray(), ""); 133 133 if (this.chart.Series[TRAINING_SERIES].Points.Count > 0) 134 134 this.chart.Series[TRAINING_SERIES].Points.DataBindXY(Content.EstimatedTrainingValues.ToArray(), "", 135 dataset.Get EnumeratedVariableValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(), "");135 dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(), ""); 136 136 if (this.chart.Series[TEST_SERIES].Points.Count > 0) 137 137 this.chart.Series[TEST_SERIES].Points.DataBindXY(Content.EstimatedTestValues.ToArray(), "", 138 dataset.Get EnumeratedVariableValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(), "");139 140 double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.Get VariableValues(targetVariableName)))).Max();141 double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.Get VariableValues(targetVariableName)))).Min();138 dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(), ""); 139 140 double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Max(); 141 double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Min(); 142 142 143 143 max = max + 0.2 * Math.Abs(max); … … 177 177 case ALL_SERIES: 178 178 predictedValues = Content.EstimatedValues.ToArray(); 179 targetValues = Content.ProblemData.Dataset.Get VariableValues(targetVariableName);179 targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName).ToArray(); 180 180 break; 181 181 case TRAINING_SERIES: 182 182 predictedValues = Content.EstimatedTrainingValues.ToArray(); 183 targetValues = Content.ProblemData.Dataset.Get EnumeratedVariableValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray();183 targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(); 184 184 break; 185 185 case TEST_SERIES: 186 186 predictedValues = Content.EstimatedTestValues.ToArray(); 187 targetValues = Content.ProblemData.Dataset.Get EnumeratedVariableValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray();187 targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(); 188 188 break; 189 189 } … … 219 219 e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[TEST_SERIES].Points.Count == 0 ? Color.Gray : Color.Black; 220 220 } 221 222 private void chart_PostPaint(object sender, ChartPaintEventArgs e) { 223 var chartArea = e.ChartElement as ChartArea; 224 if (chartArea != null) { 225 ChartGraphics chartGraphics = e.ChartGraphics; 226 using (Pen p = new Pen(Color.DarkGray)) { 227 double xmin = chartArea.AxisX.ScaleView.ViewMinimum; 228 double xmax = chartArea.AxisX.ScaleView.ViewMaximum; 229 double ymin = chartArea.AxisY.ScaleView.ViewMinimum; 230 double ymax = chartArea.AxisY.ScaleView.ViewMaximum; 231 232 if (xmin > ymax || ymin > xmax) return; 233 234 PointF start = PointF.Empty; 235 start.X = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisX.AxisName, Math.Max(xmin, ymin)); 236 start.Y = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisY.AxisName, Math.Max(xmin, ymin)); 237 PointF end = PointF.Empty; 238 end.X = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisX.AxisName, Math.Min(xmax, ymax)); 239 end.Y = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisY.AxisName, Math.Min(xmax, ymax)); 240 241 chartGraphics.Graphics.DrawLine(p, chartGraphics.GetAbsolutePoint(start), chartGraphics.GetAbsolutePoint(end)); 242 } 243 } 244 } 221 245 } 222 246 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClusteringSolutionView.cs
r6675 r6784 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core; 23 24 using HeuristicLab.MainForm; 24 25 … … 39 40 protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { 40 41 validDragOperation = false; 41 if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is ClusteringProblemData)) { 42 validDragOperation = true; 42 if (ReadOnly) return; 43 44 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 45 if (dropData is ClusteringProblemData) validDragOperation = true; 46 else if (dropData is IValueParameter) { 47 var param = (IValueParameter)dropData; 48 if (param.Value is ClusteringProblemData) validDragOperation = true; 43 49 } 44 50 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs
r6675 r6784 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Core.Views; 28 29 using HeuristicLab.MainForm; … … 139 140 protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { 140 141 validDragOperation = false; 141 if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is DataAnalysisProblemData)) { 142 validDragOperation = true; 142 if (ReadOnly) return; 143 144 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 145 if (dropData is DataAnalysisProblemData) validDragOperation = true; 146 else if (dropData is IValueParameter) { 147 var param = (IValueParameter)dropData; 148 if (param.Value is DataAnalysisProblemData) validDragOperation = true; 143 149 } 144 150 } … … 146 152 protected override void itemsListView_DragDrop(object sender, DragEventArgs e) { 147 153 if (e.Effect != DragDropEffects.None) { 148 if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is DataAnalysisProblemData) { 149 DataAnalysisProblemData problemData = (DataAnalysisProblemData)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 154 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 155 if (dropData is DataAnalysisProblemData) { 156 DataAnalysisProblemData problemData = (DataAnalysisProblemData)dropData; 150 157 Content.ProblemData = (DataAnalysisProblemData)problemData.Clone(); 158 } else if (dropData is IValueParameter) { 159 var param = (IValueParameter)dropData; 160 DataAnalysisProblemData problemData = param.Value as DataAnalysisProblemData; 161 if (problemData != null) 162 Content.ProblemData = (DataAnalysisProblemData)problemData.Clone(); 151 163 } 152 164 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/NamedDataAnalysisSolutionView.cs
r6675 r6784 30 30 [Content(typeof(DataAnalysisSolution), true)] 31 31 public partial class NamedDataAnalysisSolutionView : NamedItemView { 32 private Type contentType; 33 private DataAnalysisSolutionView view; 34 32 35 public NamedDataAnalysisSolutionView() { 33 36 InitializeComponent(); … … 41 44 protected override void OnContentChanged() { 42 45 base.OnContentChanged(); 43 panel.Controls.Clear();44 46 45 if (Content != null) { 47 if (Content == null) { 48 panel.Controls.Clear(); 49 } else if (Content.GetType() == contentType && view != null) { 50 view.Content = Content; 51 } else { 52 view = null; 53 contentType = Content.GetType(); 54 panel.Controls.Clear(); 46 55 var viewType = MainFormManager.GetViewTypes(Content.GetType(), true).Where(t => typeof(DataAnalysisSolutionView).IsAssignableFrom(t)).FirstOrDefault(); 47 56 if (viewType != null) { 48 v ar view = (DataAnalysisSolutionView)Activator.CreateInstance(viewType);57 view = (DataAnalysisSolutionView)Activator.CreateInstance(viewType); 49 58 view.Dock = DockStyle.Fill; 50 59 view.Content = Content;
Note: See TracChangeset
for help on using the changeset viewer.