- Timestamp:
- 12/21/18 14:20:24 (6 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Problems.DataAnalysis.Views
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4 merged eligible /branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4 16029-16421 /branches/Async/HeuristicLab.Problems.DataAnalysis.Views/3.4 13329-15286 /branches/Benchmarking/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4 6917-7005 /branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4 9116-13099 /branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis.Views/3.4 5815-6180 /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.4 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4 10085-11101 /branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4 8036-8538 /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis.Views/3.4 5060 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4 11570-12508 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.DataAnalysis.Views/3.4 11130-12721 /branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4 13780-14091 /branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4 7098-8789 /branches/NET40/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.DataAnalysis.Views/3.4 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Views/3.4 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis.Views/3.4 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.DataAnalysis.Views/3.4 6828 /branches/SimplifierViewsProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4 15318-15370 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.4 5370-5682 /branches/Trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4 6829-6865 /branches/VNS/HeuristicLab.Problems.DataAnalysis.Views/3.4 5594-5752 /branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4 5959-6341 /branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views/3.4 14232-14825 /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4 9568,9845,9859-9860,9865-9868,9893-9896,9900-9901,9905,9907,9973-9975,9994,10173-10176,10500,10526,10540-10541,10543,10545,10941,11031,11093,11114,11116,11156,11214,11367,11623,11631,11634,12137,12151-12152,12365,12493,12509-12511,12524,12577-12578,12614,12642,12670,12679,12722,12770,12772,12790-12792,12796,12798,12801,12811-12812,12817,12836-12837,12907,12971,13002-13004,13087,13100-13104,13154,13167-13169,13186,13268,13406,13428-13430,13434,13439,13450,13474,13501,13503,13511,13513,13534-13535,13540,13550,13552,13592-13593,13645,13648,13650-13652,13654,13657-13659,13661-13662,13666,13669,13682-13684,13690-13693,13704-13705,13708-13709,13711,13715,13724,13746,13764-13766,13807,13938,13942,13958,13985-13987,13992-13993,14000-14001,14007-14008,14014-14016,14095-14096,14098-14099,14107,14118-14119,14131,14135,14142,14152,14155-14160,14226,14228-14230,14234-14236,14244-14247,14250,14255-14258,14260,14267,14271-14272,14282,14284-14292,14296-14298,14300,14307,14314-14316,14319,14322,14332,14343-14350,14358,14367-14368,14378,14381-14382,14384,14388,14390-14391,14393-14394,14396,14400,14405,14407-14408,14418,14422-14423,14425,14434,14463-14464,14468-14469,14479,14483,14486,14507,14517,14523,14527,14529,14531-14533,14553,14623,14630,14770,14772,14781,14789-14791,14805,14826-14827,14829-14832,14839-14840,14843,14845-14847,14851-14854,14857,14864-14865,14871,14889-14890,14899,14904,14918,14937-14938,14940,14943-14946,14948-14951,15002,15013,15015-15016,15023-15024,15026,15046,15052-15054,15058,15077,15085,15088,15094,15103-15106,15111-15113,15122-15124,15129,15139,15160,15163,15165,15184-15185,15187,15194,15211,15213,15222,15287,15371-15372,15390,15395,15400,15402,15427,15486
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r16435 r16438 55 55 this.dataPartitionLabel = new System.Windows.Forms.Label(); 56 56 this.dataPartitionComboBox = new System.Windows.Forms.ComboBox(); 57 this.variableIm actsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();57 this.variableImpactsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView(); 58 58 this.SuspendLayout(); 59 59 // … … 61 61 // 62 62 this.ascendingCheckBox.AutoSize = true; 63 this.ascendingCheckBox.Location = new System.Drawing.Point(534, 6); 63 this.ascendingCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 64 this.ascendingCheckBox.Location = new System.Drawing.Point(452, 32); 64 65 this.ascendingCheckBox.Name = "ascendingCheckBox"; 65 66 this.ascendingCheckBox.Size = new System.Drawing.Size(76, 17); … … 162 163 this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged); 163 164 // 164 // variableIm actsArrayView165 // 166 this.variableIm actsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)167 | System.Windows.Forms.AnchorStyles.Left) 165 // variableImpactsArrayView 166 // 167 this.variableImpactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 168 | System.Windows.Forms.AnchorStyles.Left) 168 169 | System.Windows.Forms.AnchorStyles.Right))); 169 this.variableIm actsArrayView.Caption = "StringConvertibleArray View";170 this.variableIm actsArrayView.Content = null;171 this.variableIm actsArrayView.Location = new System.Drawing.Point(3, 84);172 this.variableIm actsArrayView.Name = "variableImactsArrayView";173 this.variableIm actsArrayView.ReadOnly = true;174 this.variableIm actsArrayView.Size = new System.Drawing.Size(706, 278);175 this.variableIm actsArrayView.TabIndex = 2;170 this.variableImpactsArrayView.Caption = "StringConvertibleArray View"; 171 this.variableImpactsArrayView.Content = null; 172 this.variableImpactsArrayView.Location = new System.Drawing.Point(3, 84); 173 this.variableImpactsArrayView.Name = "variableImpactsArrayView"; 174 this.variableImpactsArrayView.ReadOnly = true; 175 this.variableImpactsArrayView.Size = new System.Drawing.Size(706, 278); 176 this.variableImpactsArrayView.TabIndex = 2; 176 177 // 177 178 // RegressionSolutionVariableImpactsView … … 188 189 this.Controls.Add(this.dataPartitionLabel); 189 190 this.Controls.Add(this.dataPartitionComboBox); 190 this.Controls.Add(this.variableIm actsArrayView);191 this.Controls.Add(this.variableImpactsArrayView); 191 192 this.Name = "RegressionSolutionVariableImpactsView"; 192 193 this.Size = new System.Drawing.Size(712, 365); … … 199 200 #endregion 200 201 201 private Data.Views.StringConvertibleArrayView variableIm actsArrayView;202 private Data.Views.StringConvertibleArrayView variableImpactsArrayView; 202 203 private System.Windows.Forms.ComboBox dataPartitionComboBox; 203 204 private System.Windows.Forms.Label dataPartitionLabel; -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r16435 r16438 33 33 [Content(typeof(IRegressionSolution))] 34 34 public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 35 private CancellationTokenSource cancellationToken = new CancellationTokenSource();36 35 private enum SortingCriteria { 37 36 ImpactValue, … … 39 38 VariableName 40 39 } 40 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 42 … … 64 64 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 65 65 } 66 67 66 protected override void DeregisterContentEvents() { 68 67 base.DeregisterContentEvents(); … … 74 73 OnContentChanged(); 75 74 } 76 77 75 protected virtual void Content_ModelChanged(object sender, EventArgs e) { 78 76 OnContentChanged(); 79 77 } 80 81 78 protected override void OnContentChanged() { 82 79 base.OnContentChanged(); 80 rawVariableImpacts.Clear(); 81 83 82 if (Content == null) { 84 variableIm actsArrayView.Content = null;83 variableImpactsArrayView.Content = null; 85 84 } else { 86 85 UpdateVariableImpact(); 87 86 } 88 87 } 89 90 88 private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 91 89 cancellationToken.Cancel(); 92 90 } 93 91 94 95 92 private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) { 93 rawVariableImpacts.Clear(); 96 94 UpdateVariableImpact(); 97 95 } 98 99 96 private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) { 97 rawVariableImpacts.Clear(); 100 98 UpdateVariableImpact(); 101 99 } 102 103 100 private void sortByComboBox_SelectedIndexChanged(object sender, EventArgs e) { 104 101 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) … … 109 106 UpdateOrdering(); 110 107 } 111 112 108 private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) { 113 109 UpdateOrdering(); 114 110 } 115 116 111 117 112 private async void UpdateVariableImpact() { … … 130 125 var dataPartition = (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 131 126 132 variableIm actsArrayView.Caption = Content.Name + " Variable Impacts";127 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 133 128 progress = mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name); 134 129 progress.ProgressValue = 0; 135 130 136 131 cancellationToken = new CancellationTokenSource(); 137 //Remember the original ordering of the variables 132 138 133 try { 139 var impacts = await Task.Run(() => RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod,140 (i, s) => {141 progress.ProgressValue = i;142 progress.Status = s;143 return cancellationToken.Token.IsCancellationRequested;144 }), cancellationToken.Token);145 146 if (cancellationToken.Token.IsCancellationRequested) { return; }147 134 var problemData = Content.ProblemData; 148 135 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 136 //Remember the original ordering of the variables 149 137 var originalVariableOrdering = problemData.Dataset.VariableNames 150 138 .Where(v => inputvariables.Contains(v)) … … 152 140 .ToList(); 153 141 154 rawVariableImpacts.Clear(); 155 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2))); 142 List<Tuple<string, double>> impacts = null; 143 await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); }); 144 if (impacts == null) { return; } 145 146 rawVariableImpacts.AddRange(impacts); 156 147 UpdateOrdering(); 157 } finally { 148 } 149 finally { 158 150 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this); 159 151 } 160 152 } 153 private List<Tuple<string, double>> CalculateVariableImpacts(List<string> originalVariableOrdering, 154 IRegressionModel model, 155 IRegressionProblemData problemData, 156 IEnumerable<double> estimatedValues, 157 RegressionSolutionVariableImpactsCalculator.DataPartitionEnum dataPartition, 158 RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum replMethod, 159 RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum factorReplMethod, 160 CancellationToken token, 161 IProgress progress) { 162 List<Tuple<string, double>> impacts = new List<Tuple<string, double>>(); 163 int count = originalVariableOrdering.Count; 164 int i = 0; 165 var modifiableDataset = ((Dataset)(problemData.Dataset).Clone()).ToModifiable(); 166 IEnumerable<int> rows = RegressionSolutionVariableImpactsCalculator.GetPartitionRows(dataPartition, problemData); 167 168 //Calculate original quality-values (via calculator, default is R²) 169 IEnumerable<double> targetValuesPartition = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 170 IEnumerable<double> estimatedValuesPartition = Content.GetEstimatedValues(rows); 171 172 var originalCalculatorValue = RegressionSolutionVariableImpactsCalculator.CalculateQuality(targetValuesPartition, estimatedValuesPartition); 173 174 foreach (var variableName in originalVariableOrdering) { 175 if (cancellationToken.Token.IsCancellationRequested) { return null; } 176 progress.ProgressValue = (double)++i / count; 177 progress.Status = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count); 178 179 double impact = 0; 180 //If the variable isn't used for prediction, it has zero impact. 181 if (model.VariablesUsedForPrediction.Contains(variableName)) { 182 impact = RegressionSolutionVariableImpactsCalculator.CalculateImpact(variableName, model, problemData, modifiableDataset, rows, replMethod, factorReplMethod, targetValuesPartition, originalCalculatorValue); 183 } 184 impacts.Add(new Tuple<string, double>(variableName, impact)); 185 } 186 187 return impacts; 188 } 161 189 162 190 /// <summary> 163 /// Updates the <see cref="variableIm actsArrayView"/> according to the selected ordering <see cref="ascendingCheckBox"/> of the selected Column <see cref="sortByComboBox"/>191 /// Updates the <see cref="variableImpactsArrayView"/> according to the selected ordering <see cref="ascendingCheckBox"/> of the selected Column <see cref="sortByComboBox"/> 164 192 /// The default is "Descending" by "VariableImpact" (as in previous versions) 165 193 /// </summary> … … 198 226 199 227 //Could be, if the View was closed 200 if (!variableIm actsArrayView.IsDisposed) {201 variableIm actsArrayView.Content = (DoubleArray)impactArray.AsReadOnly();228 if (!variableImpactsArrayView.IsDisposed) { 229 variableImpactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 202 230 } 203 231 }
Note: See TracChangeset
for help on using the changeset viewer.