Changeset 16422 for trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Timestamp:
- 12/20/18 13:29:51 (6 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Views
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Views
-
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/2904_CalculateImpacts/HeuristicLab.Problems.DataAnalysis.Views/3.4 merged eligible /stable/HeuristicLab.Problems.DataAnalysis.Views/3.4 merged eligible /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-5599 /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
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.Designer.cs
r15753 r16422 19 19 */ 20 20 #endregion 21 22 21 23 namespace HeuristicLab.Problems.DataAnalysis.Views { 22 24 partial class ClassificationSolutionVariableImpactsView { … … 44 46 /// </summary> 45 47 private void InitializeComponent() { 46 this.variableImactsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();47 this.dataPartitionComboBox = new System.Windows.Forms.ComboBox();48 this.dataPartitionLabel = new System.Windows.Forms.Label();49 this.numericVarReplacementLabel = new System.Windows.Forms.Label();50 this.replacementComboBox = new System.Windows.Forms.ComboBox();51 this.factorVarReplacementLabel = new System.Windows.Forms.Label();52 this.factorVarReplComboBox = new System.Windows.Forms.ComboBox();53 48 this.ascendingCheckBox = new System.Windows.Forms.CheckBox(); 54 49 this.sortByLabel = new System.Windows.Forms.Label(); 55 50 this.sortByComboBox = new System.Windows.Forms.ComboBox(); 56 this.backgroundWorker = new System.ComponentModel.BackgroundWorker(); 51 this.factorVarReplComboBox = new System.Windows.Forms.ComboBox(); 52 this.factorVarReplacementLabel = new System.Windows.Forms.Label(); 53 this.replacementComboBox = new System.Windows.Forms.ComboBox(); 54 this.numericVarReplacementLabel = new System.Windows.Forms.Label(); 55 this.dataPartitionLabel = new System.Windows.Forms.Label(); 56 this.dataPartitionComboBox = new System.Windows.Forms.ComboBox(); 57 this.variableImpactsArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView(); 57 58 this.SuspendLayout(); 58 59 // 59 // variableImactsArrayView 60 // 61 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 62 | System.Windows.Forms.AnchorStyles.Left) 63 | System.Windows.Forms.AnchorStyles.Right))); 64 this.variableImactsArrayView.Caption = "StringConvertibleArray View"; 65 this.variableImactsArrayView.Content = null; 66 this.variableImactsArrayView.Location = new System.Drawing.Point(3, 84); 67 this.variableImactsArrayView.Name = "variableImactsArrayView"; 68 this.variableImactsArrayView.ReadOnly = true; 69 this.variableImactsArrayView.Size = new System.Drawing.Size(662, 278); 70 this.variableImactsArrayView.TabIndex = 2; 71 // 72 // dataPartitionComboBox 73 // 74 this.dataPartitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 75 this.dataPartitionComboBox.FormattingEnabled = true; 76 this.dataPartitionComboBox.Items.AddRange(new object[] { 77 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.Training, 78 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.Test, 79 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.All}); 80 this.dataPartitionComboBox.Location = new System.Drawing.Point(197, 3); 81 this.dataPartitionComboBox.Name = "dataPartitionComboBox"; 82 this.dataPartitionComboBox.Size = new System.Drawing.Size(121, 21); 83 this.dataPartitionComboBox.TabIndex = 1; 84 this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged); 85 // 86 // dataPartitionLabel 87 // 88 this.dataPartitionLabel.AutoSize = true; 89 this.dataPartitionLabel.Location = new System.Drawing.Point(3, 6); 90 this.dataPartitionLabel.Name = "dataPartitionLabel"; 91 this.dataPartitionLabel.Size = new System.Drawing.Size(73, 13); 92 this.dataPartitionLabel.TabIndex = 0; 93 this.dataPartitionLabel.Text = "Data partition:"; 94 // 95 // numericVarReplacementLabel 96 // 97 this.numericVarReplacementLabel.AutoSize = true; 98 this.numericVarReplacementLabel.Location = new System.Drawing.Point(3, 33); 99 this.numericVarReplacementLabel.Name = "numericVarReplacementLabel"; 100 this.numericVarReplacementLabel.Size = new System.Drawing.Size(173, 13); 101 this.numericVarReplacementLabel.TabIndex = 2; 102 this.numericVarReplacementLabel.Text = "Replacement for numeric variables:"; 60 // ascendingCheckBox 61 // 62 this.ascendingCheckBox.AutoSize = true; 63 this.ascendingCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 64 this.ascendingCheckBox.Location = new System.Drawing.Point(452, 32); 65 this.ascendingCheckBox.Name = "ascendingCheckBox"; 66 this.ascendingCheckBox.Size = new System.Drawing.Size(76, 17); 67 this.ascendingCheckBox.TabIndex = 7; 68 this.ascendingCheckBox.Text = "Ascending"; 69 this.ascendingCheckBox.UseVisualStyleBackColor = true; 70 this.ascendingCheckBox.CheckedChanged += new System.EventHandler(this.ascendingCheckBox_CheckedChanged); 71 // 72 // sortByLabel 73 // 74 this.sortByLabel.AutoSize = true; 75 this.sortByLabel.Location = new System.Drawing.Point(324, 6); 76 this.sortByLabel.Name = "sortByLabel"; 77 this.sortByLabel.Size = new System.Drawing.Size(77, 13); 78 this.sortByLabel.TabIndex = 4; 79 this.sortByLabel.Text = "Sorting criteria:"; 80 // 81 // sortByComboBox 82 // 83 this.sortByComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 84 this.sortByComboBox.FormattingEnabled = true; 85 this.sortByComboBox.Items.AddRange(new object[] { 86 HeuristicLab.Problems.DataAnalysis.Views.ClassificationSolutionVariableImpactsView.SortingCriteria.ImpactValue, 87 HeuristicLab.Problems.DataAnalysis.Views.ClassificationSolutionVariableImpactsView.SortingCriteria.Occurrence, 88 HeuristicLab.Problems.DataAnalysis.Views.ClassificationSolutionVariableImpactsView.SortingCriteria.VariableName}); 89 this.sortByComboBox.Location = new System.Drawing.Point(407, 3); 90 this.sortByComboBox.Name = "sortByComboBox"; 91 this.sortByComboBox.Size = new System.Drawing.Size(121, 21); 92 this.sortByComboBox.TabIndex = 5; 93 this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged); 94 // 95 // factorVarReplComboBox 96 // 97 this.factorVarReplComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 98 this.factorVarReplComboBox.FormattingEnabled = true; 99 this.factorVarReplComboBox.Items.AddRange(new object[] { 100 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Best, 101 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Mode, 102 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Shuffle}); 103 this.factorVarReplComboBox.Location = new System.Drawing.Point(197, 57); 104 this.factorVarReplComboBox.Name = "factorVarReplComboBox"; 105 this.factorVarReplComboBox.Size = new System.Drawing.Size(121, 21); 106 this.factorVarReplComboBox.TabIndex = 1; 107 this.factorVarReplComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged); 108 // 109 // factorVarReplacementLabel 110 // 111 this.factorVarReplacementLabel.AutoSize = true; 112 this.factorVarReplacementLabel.Location = new System.Drawing.Point(3, 60); 113 this.factorVarReplacementLabel.Name = "factorVarReplacementLabel"; 114 this.factorVarReplacementLabel.Size = new System.Drawing.Size(188, 13); 115 this.factorVarReplacementLabel.TabIndex = 0; 116 this.factorVarReplacementLabel.Text = "Replacement for categorical variables:"; 103 117 // 104 118 // replacementComboBox … … 117 131 this.replacementComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged); 118 132 // 119 // factorVarReplacementLabel 120 // 121 this.factorVarReplacementLabel.AutoSize = true; 122 this.factorVarReplacementLabel.Location = new System.Drawing.Point(3, 60); 123 this.factorVarReplacementLabel.Name = "factorVarReplacementLabel"; 124 this.factorVarReplacementLabel.Size = new System.Drawing.Size(188, 13); 125 this.factorVarReplacementLabel.TabIndex = 0; 126 this.factorVarReplacementLabel.Text = "Replacement for categorical variables:"; 127 // 128 // factorVarReplComboBox 129 // 130 this.factorVarReplComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 131 this.factorVarReplComboBox.FormattingEnabled = true; 132 this.factorVarReplComboBox.Items.AddRange(new object[] { 133 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Best, 134 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Mode, 135 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum.Shuffle}); 136 this.factorVarReplComboBox.Location = new System.Drawing.Point(197, 57); 137 this.factorVarReplComboBox.Name = "factorVarReplComboBox"; 138 this.factorVarReplComboBox.Size = new System.Drawing.Size(121, 21); 139 this.factorVarReplComboBox.TabIndex = 1; 140 this.factorVarReplComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged); 141 // 142 // ascendingCheckBox 143 // 144 this.ascendingCheckBox.AutoSize = true; 145 this.ascendingCheckBox.Location = new System.Drawing.Point(534, 6); 146 this.ascendingCheckBox.Name = "ascendingCheckBox"; 147 this.ascendingCheckBox.Size = new System.Drawing.Size(76, 17); 148 this.ascendingCheckBox.TabIndex = 10; 149 this.ascendingCheckBox.Text = "Ascending"; 150 this.ascendingCheckBox.UseVisualStyleBackColor = true; 151 this.ascendingCheckBox.CheckedChanged += new System.EventHandler(this.ascendingCheckBox_CheckedChanged); 152 // 153 // sortByLabel 154 // 155 this.sortByLabel.AutoSize = true; 156 this.sortByLabel.Location = new System.Drawing.Point(324, 6); 157 this.sortByLabel.Name = "sortByLabel"; 158 this.sortByLabel.Size = new System.Drawing.Size(77, 13); 159 this.sortByLabel.TabIndex = 8; 160 this.sortByLabel.Text = "Sorting criteria:"; 161 // 162 // sortByComboBox 163 // 164 this.sortByComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 165 this.sortByComboBox.FormattingEnabled = true; 166 this.sortByComboBox.Location = new System.Drawing.Point(407, 3); 167 this.sortByComboBox.Name = "sortByComboBox"; 168 this.sortByComboBox.Size = new System.Drawing.Size(121, 21); 169 this.sortByComboBox.TabIndex = 9; 170 this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged); 133 // numericVarReplacementLabel 134 // 135 this.numericVarReplacementLabel.AutoSize = true; 136 this.numericVarReplacementLabel.Location = new System.Drawing.Point(3, 33); 137 this.numericVarReplacementLabel.Name = "numericVarReplacementLabel"; 138 this.numericVarReplacementLabel.Size = new System.Drawing.Size(173, 13); 139 this.numericVarReplacementLabel.TabIndex = 2; 140 this.numericVarReplacementLabel.Text = "Replacement for numeric variables:"; 141 // 142 // dataPartitionLabel 143 // 144 this.dataPartitionLabel.AutoSize = true; 145 this.dataPartitionLabel.Location = new System.Drawing.Point(3, 6); 146 this.dataPartitionLabel.Name = "dataPartitionLabel"; 147 this.dataPartitionLabel.Size = new System.Drawing.Size(73, 13); 148 this.dataPartitionLabel.TabIndex = 0; 149 this.dataPartitionLabel.Text = "Data partition:"; 150 // 151 // dataPartitionComboBox 152 // 153 this.dataPartitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 154 this.dataPartitionComboBox.FormattingEnabled = true; 155 this.dataPartitionComboBox.Items.AddRange(new object[] { 156 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.Training, 157 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.Test, 158 HeuristicLab.Problems.DataAnalysis.ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum.All}); 159 this.dataPartitionComboBox.Location = new System.Drawing.Point(197, 3); 160 this.dataPartitionComboBox.Name = "dataPartitionComboBox"; 161 this.dataPartitionComboBox.Size = new System.Drawing.Size(121, 21); 162 this.dataPartitionComboBox.TabIndex = 1; 163 this.dataPartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.dataPartitionComboBox_SelectedIndexChanged); 164 // 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) 169 | System.Windows.Forms.AnchorStyles.Right))); 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; 171 177 // 172 178 // ClassificationSolutionVariableImpactsView … … 183 189 this.Controls.Add(this.dataPartitionLabel); 184 190 this.Controls.Add(this.dataPartitionComboBox); 185 this.Controls.Add(this.variableIm actsArrayView);191 this.Controls.Add(this.variableImpactsArrayView); 186 192 this.Name = "ClassificationSolutionVariableImpactsView"; 187 this.Size = new System.Drawing.Size( 668, 365);193 this.Size = new System.Drawing.Size(712, 365); 188 194 this.VisibleChanged += new System.EventHandler(this.ClassificationSolutionVariableImpactsView_VisibleChanged); 189 195 this.ResumeLayout(false); … … 194 200 #endregion 195 201 196 private Data.Views.StringConvertibleArrayView variableIm actsArrayView;202 private Data.Views.StringConvertibleArrayView variableImpactsArrayView; 197 203 private System.Windows.Forms.ComboBox dataPartitionComboBox; 198 204 private System.Windows.Forms.Label dataPartitionLabel; … … 201 207 private System.Windows.Forms.Label factorVarReplacementLabel; 202 208 private System.Windows.Forms.ComboBox factorVarReplComboBox; 203 private System.Windows.Forms.CheckBox ascendingCheckBox;204 209 private System.Windows.Forms.Label sortByLabel; 205 210 private System.Windows.Forms.ComboBox sortByComboBox; 206 private System. ComponentModel.BackgroundWorker backgroundWorker;211 private System.Windows.Forms.CheckBox ascendingCheckBox; 207 212 } 208 213 } -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r16232 r16422 33 33 [Content(typeof(IClassificationSolution))] 34 34 public partial class ClassificationSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 35 #region Nested Types36 35 private enum SortingCriteria { 37 36 ImpactValue, … … 39 38 VariableName 40 39 } 41 #endregion 42 43 #region Fields 44 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 45 private Thread thread; 46 #endregion 47 48 #region Getter/Setter 40 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 49 43 public new IClassificationSolution Content { 50 44 get { return (IClassificationSolution)base.Content; } … … 53 47 } 54 48 } 55 #endregion 56 57 #region Ctor 49 58 50 public ClassificationSolutionVariableImpactsView() 59 51 : base() { 60 52 InitializeComponent(); 61 53 62 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray());63 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;64 65 54 //Set the default values 66 55 this.dataPartitionComboBox.SelectedIndex = 0; 67 this.replacementComboBox.SelectedIndex = 0;56 this.replacementComboBox.SelectedIndex = 3; 68 57 this.factorVarReplComboBox.SelectedIndex = 0; 69 } 70 #endregion 71 72 #region Events 58 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 59 } 60 73 61 protected override void RegisterContentEvents() { 74 62 base.RegisterContentEvents(); … … 76 64 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 77 65 } 78 79 66 protected override void DeregisterContentEvents() { 80 67 base.DeregisterContentEvents(); … … 86 73 OnContentChanged(); 87 74 } 88 89 75 protected virtual void Content_ModelChanged(object sender, EventArgs e) { 90 76 OnContentChanged(); 91 77 } 92 93 78 protected override void OnContentChanged() { 94 79 base.OnContentChanged(); 80 rawVariableImpacts.Clear(); 81 95 82 if (Content == null) { 96 variableIm actsArrayView.Content = null;83 variableImpactsArrayView.Content = null; 97 84 } else { 98 85 UpdateVariableImpact(); 99 86 } 100 87 } 101 102 88 private void ClassificationSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 103 if (thread == null) { return; } 104 105 if (thread.IsAlive) { thread.Abort(); } 106 thread = null; 107 } 108 89 cancellationToken.Cancel(); 90 } 109 91 110 92 private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) { 93 rawVariableImpacts.Clear(); 111 94 UpdateVariableImpact(); 112 95 } 113 114 96 private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) { 97 rawVariableImpacts.Clear(); 115 98 UpdateVariableImpact(); 116 99 } 117 118 100 private void sortByComboBox_SelectedIndexChanged(object sender, EventArgs e) { 119 101 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) 120 102 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 121 switch ((SortingCriteria)sortByComboBox.SelectedItem) { 122 case SortingCriteria.ImpactValue: 123 ascendingCheckBox.Checked = false; 124 break; 125 case SortingCriteria.Occurrence: 126 ascendingCheckBox.Checked = true; 127 break; 128 case SortingCriteria.VariableName: 129 ascendingCheckBox.Checked = true; 130 break; 131 default: 132 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 133 } 103 ascendingCheckBox.Checked = (SortingCriteria)sortByComboBox.SelectedItem != SortingCriteria.ImpactValue; 134 104 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; 135 105 136 UpdateDataOrdering(); 137 } 138 106 UpdateOrdering(); 107 } 139 108 private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) { 140 UpdateDataOrdering(); 141 } 142 143 #endregion 144 145 #region Helper Methods 146 private void UpdateVariableImpact() { 109 UpdateOrdering(); 110 } 111 112 private async void UpdateVariableImpact() { 113 IProgress progress; 114 147 115 //Check if the selection is valid 148 116 if (Content == null) { return; } … … 157 125 var dataPartition = (ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 158 126 159 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 160 161 mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name); 162 163 Task.Factory.StartNew(() => { 164 thread = Thread.CurrentThread; 165 //Remember the original ordering of the variables 166 var impacts = ClassificationSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod); 127 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 128 progress = mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name); 129 progress.ProgressValue = 0; 130 131 cancellationToken = new CancellationTokenSource(); 132 133 try { 167 134 var problemData = Content.ProblemData; 168 135 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 169 var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList(); 170 171 rawVariableImpacts.Clear(); 172 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 173 }).ContinueWith((o) => { 174 UpdateDataOrdering(); 175 mainForm.RemoveOperationProgressFromView(this); 176 thread = null; 177 }, TaskScheduler.FromCurrentSynchronizationContext()); 136 //Remember the original ordering of the variables 137 var originalVariableOrdering = problemData.Dataset.VariableNames 138 .Where(v => inputvariables.Contains(v)) 139 .Where(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v)) 140 .ToList(); 141 142 List<Tuple<string, double>> impacts = null; 143 await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedClassValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); }); 144 if (impacts == null) { return; } 145 146 rawVariableImpacts.AddRange(impacts); 147 UpdateOrdering(); 148 } 149 finally { 150 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this); 151 } 152 } 153 private List<Tuple<string, double>> CalculateVariableImpacts(List<string> originalVariableOrdering, 154 IClassificationModel model, 155 IClassificationProblemData problemData, 156 IEnumerable<double> estimatedClassValues, 157 ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum dataPartition, 158 ClassificationSolutionVariableImpactsCalculator.ReplacementMethodEnum replMethod, 159 ClassificationSolutionVariableImpactsCalculator.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 = ClassificationSolutionVariableImpactsCalculator.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> estimatedClassValuesPartition = Content.GetEstimatedClassValues(rows); 171 172 var originalCalculatorValue = ClassificationSolutionVariableImpactsCalculator.CalculateQuality(targetValuesPartition, estimatedClassValuesPartition); 173 var clonedModel = (IClassificationModel)model.Clone(); 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 = ClassificationSolutionVariableImpactsCalculator.CalculateImpact(variableName, clonedModel, problemData, modifiableDataset, rows, replMethod, factorReplMethod, targetValuesPartition, originalCalculatorValue); 183 } 184 impacts.Add(new Tuple<string, double>(variableName, impact)); 185 } 186 187 return impacts; 178 188 } 179 189 180 190 /// <summary> 181 /// 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"/> 182 192 /// The default is "Descending" by "VariableImpact" (as in previous versions) 183 193 /// </summary> 184 private void Update DataOrdering() {194 private void UpdateOrdering() { 185 195 //Check if valid sortingCriteria is selected and data exists 186 196 if (sortByComboBox.SelectedIndex == -1) { return; } … … 191 201 bool ascending = ascendingCheckBox.Checked; 192 202 193 IEnumerable< KeyValuePair<string, double>> orderedEntries = null;203 IEnumerable<Tuple<string, double>> orderedEntries = null; 194 204 195 205 //Sort accordingly 196 206 switch (selectedItem) { 197 207 case SortingCriteria.ImpactValue: 198 orderedEntries = rawVariableImpacts.OrderBy(v => v. Value);208 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item2); 199 209 break; 200 210 case SortingCriteria.Occurrence: … … 202 212 break; 203 213 case SortingCriteria.VariableName: 204 orderedEntries = rawVariableImpacts.OrderBy(v => v. Key, new NaturalStringComparer());214 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item1, new NaturalStringComparer()); 205 215 break; 206 216 default: … … 211 221 212 222 //Write the data back 213 var impactArray = new DoubleArray(orderedEntries.Select(i => i. Value).ToArray()) {214 ElementNames = orderedEntries.Select(i => i. Key)223 var impactArray = new DoubleArray(orderedEntries.Select(i => i.Item2).ToArray()) { 224 ElementNames = orderedEntries.Select(i => i.Item1) 215 225 }; 216 226 217 227 //Could be, if the View was closed 218 if (!variableImactsArrayView.IsDisposed) { 219 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 220 } 221 } 222 #endregion 228 if (!variableImpactsArrayView.IsDisposed) { 229 variableImpactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 230 } 231 } 223 232 } 224 233 } -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15999 r16422 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; -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r16021 r16422 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.