- Timestamp:
- 04/19/13 12:02:44 (12 years ago)
- Location:
- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ResultCorrelationView.cs
r9380 r9382 49 49 } 50 50 51 private Dictionary<string, ResultParameterType> resultsParameters; 52 51 53 protected override void OnContentChanged() { 52 54 base.OnContentChanged(); … … 54 56 55 57 if (Content != null) { 58 resultsParameters = GetRowNames(); 56 59 UpdateResultComboBox(); 57 60 } … … 64 67 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 65 68 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 66 67 RegisterRunEvents(Content); 68 } 69 70 private void RegisterRunEvents(IEnumerable<IRun> runs) { 71 foreach (IRun run in runs) 72 run.Changed += new EventHandler(run_Changed); 69 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 73 70 } 74 71 … … 78 75 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 79 76 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 80 81 DeregisterRunEvents(Content); 82 } 83 84 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 85 foreach (IRun run in runs) 86 run.Changed -= new EventHandler(run_Changed); 77 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 87 78 } 88 79 89 80 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 90 DeregisterRunEvents(e.OldItems); 91 RegisterRunEvents(e.Items); 92 //RebuildInfluenceDataTable(); 81 RebuildCorrelationTable(); 93 82 } 94 83 95 84 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 96 DeregisterRunEvents(e.Items); 97 //RebuildInfluenceDataTable(); 85 RebuildCorrelationTable(); 98 86 } 99 87 100 88 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 101 RegisterRunEvents(e.Items); 102 //RebuildInfluenceDataTable(); 103 } 104 105 private void run_Changed(object sender, EventArgs e) { 106 if (InvokeRequired) 107 this.Invoke(new EventHandler(run_Changed), sender, e); 108 else { 109 IRun run = (IRun)sender; 110 UpdateRun(run); 89 RebuildCorrelationTable(); 90 } 91 92 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 93 if (!Content.UpdateOfRunsInProgress) { 94 RebuildCorrelationTable(); 111 95 } 112 96 } 113 97 #endregion 114 115 private void UpdateRun(IRun run) {116 //TODO: hacky di hack... this is baaaadddd117 RebuildCorrelationTable();118 }119 98 120 99 private void UpdateResultComboBox() { 121 100 resultComboBox.Items.Clear(); 101 102 resultComboBox.Items.AddRange(resultsParameters.Keys.ToArray()); 103 if (resultComboBox.Items.Count > 0) resultComboBox.SelectedItem = resultComboBox.Items[0]; 104 } 105 106 private List<string> GetResultRowNames() { 122 107 var results = (from run in Content 108 where run.Visible 123 109 from result in run.Results 124 select result.Key).Distinct().ToArray(); 125 126 resultComboBox.Items.AddRange(results); 127 if (resultComboBox.Items.Count > 0) resultComboBox.SelectedItem = resultComboBox.Items[0]; 128 } 129 130 131 private List<string> GetRowNames() { 132 string resultName = (string)resultComboBox.SelectedItem; 133 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible); 134 List<string> ret = new List<string>(); 110 where result.Value is DoubleValue || result.Value is IntValue 111 select result.Key).Distinct().ToList(); 112 113 return results; 114 } 115 116 private List<string> GetParameterRowNames() { 117 var parameters = (from run in Content 118 where run.Visible 119 from parameter in run.Parameters 120 where parameter.Value is DoubleValue || parameter.Value is IntValue 121 select parameter.Key).Distinct().ToList(); 122 123 return parameters; 124 } 125 126 private Dictionary<string, ResultParameterType> GetRowNames() { 127 Dictionary<string, ResultParameterType> ret = new Dictionary<string, ResultParameterType>(); 128 129 var results = GetResultRowNames(); 130 var parameters = GetParameterRowNames(); 131 132 foreach (var r in results) { 133 ret.Add(r, ResultParameterType.Result); 134 } 135 foreach (var p in parameters) { 136 if (!ret.ContainsKey(p)) { 137 ret.Add(p, ResultParameterType.Parameter); 138 } 139 } 140 141 return ret; 142 } 143 144 private List<double> GetDoublesFromResults(List<IRun> runs, string key) { 145 List<double> res = new List<double>(); 135 146 136 147 foreach (var r in runs) { 137 var ress = r.Results.Where(y => y.Value is DoubleValue).Select(z => z.Key); 138 foreach (var s in ress) { 139 if (!ret.Contains(s)) 140 ret.Add(s); 141 } 142 } 143 144 return ret; 148 if (r.Results[key] is DoubleValue) { 149 res.Add(((DoubleValue)r.Results[key]).Value); 150 } else { 151 res.Add(((IntValue)r.Results[key]).Value); 152 } 153 } 154 return res; 155 } 156 157 private List<double> GetDoublesFromParameters(List<IRun> runs, string key) { 158 List<double> res = new List<double>(); 159 160 foreach (var r in runs) { 161 if (r.Parameters[key] is DoubleValue) { 162 res.Add(((DoubleValue)r.Parameters[key]).Value); 163 } else { 164 res.Add(((IntValue)r.Parameters[key]).Value); 165 } 166 } 167 return res; 145 168 } 146 169 … … 151 174 columnNames[0] = "Pearson product-moment correlation coefficient"; 152 175 columnNames[1] = "Spearman's rank correlation coefficient"; 153 var rowNames = GetRowNames(); 176 154 177 155 178 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible); 156 179 157 DoubleMatrix dt = new DoubleMatrix(r owNames.Count(), columnNames.Count());158 dt.RowNames = r owNames;180 DoubleMatrix dt = new DoubleMatrix(resultsParameters.Count(), columnNames.Count()); 181 dt.RowNames = resultsParameters.Keys.ToArray(); 159 182 dt.ColumnNames = columnNames; 160 183 161 184 int j = 0; 162 foreach (var rowName in rowNames) { 163 var resultRowVals = runs.Where(x => x.Results.ContainsKey(rowName)).Where(x => x.Results[rowName] is DoubleValue).Select(x => ((DoubleValue)x.Results[rowName]).Value); 164 var resultVals = runs.Where(x => x.Results.ContainsKey(resultName)).Where(x => x.Results[resultName] is DoubleValue).Select(x => ((DoubleValue)x.Results[resultName]).Value); 185 foreach (var rowName in resultsParameters) { 186 var resultVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(resultName)).Where(x => x.Results[resultName] is DoubleValue || x.Results[resultName] is IntValue).ToList(), resultName); 187 188 List<double> resultRowVals = new List<double>(); 189 if (rowName.Value == ResultParameterType.Result) { 190 resultRowVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(rowName.Key)).Where(x => x.Results[rowName.Key] is DoubleValue || x.Results[rowName.Key] is IntValue).ToList(), rowName.Key); 191 } else { 192 resultRowVals = GetDoublesFromParameters(runs.Where(x => x.Parameters.ContainsKey(rowName.Key)).Where(x => x.Parameters[rowName.Key] is DoubleValue || x.Parameters[rowName.Key] is IntValue).ToList(), rowName.Key); 193 } 165 194 166 195 if (resultVals.Contains(double.NaN) … … 184 213 RebuildCorrelationTable(); 185 214 } 215 216 private enum ResultParameterType { 217 Result, 218 Parameter 219 } 186 220 } 187 221 } -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ResultCorrelationView.designer.cs
r9380 r9382 60 60 this.stringConvertibleMatrixView.Location = new System.Drawing.Point(3, 30); 61 61 this.stringConvertibleMatrixView.Name = "stringConvertibleMatrixView"; 62 this.stringConvertibleMatrixView.ReadOnly = false;62 this.stringConvertibleMatrixView.ReadOnly = true; 63 63 this.stringConvertibleMatrixView.ShowRowsAndColumnsTextBox = true; 64 64 this.stringConvertibleMatrixView.ShowStatisticalInformation = true;
Note: See TracChangeset
for help on using the changeset viewer.