Changeset 15626
- Timestamp:
- 01/17/18 14:11:45 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15583 r15626 51 51 this.factorVarReplacementLabel = new System.Windows.Forms.Label(); 52 52 this.factorVarReplComboBox = new System.Windows.Forms.ComboBox(); 53 this.sortByLabel = new System.Windows.Forms.Label(); 54 this.sortByComboBox = new System.Windows.Forms.ComboBox(); 55 this.ascendingCheckBox = new System.Windows.Forms.CheckBox(); 53 56 this.SuspendLayout(); 54 57 // 55 58 // variableImactsArrayView 56 59 // 57 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 58 | System.Windows.Forms.AnchorStyles.Left) 60 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 61 | System.Windows.Forms.AnchorStyles.Left) 59 62 | System.Windows.Forms.AnchorStyles.Right))); 60 63 this.variableImactsArrayView.Caption = "StringConvertibleArray View"; … … 63 66 this.variableImactsArrayView.Name = "variableImactsArrayView"; 64 67 this.variableImactsArrayView.ReadOnly = true; 65 this.variableImactsArrayView.Size = new System.Drawing.Size( 363, 278);68 this.variableImactsArrayView.Size = new System.Drawing.Size(706, 278); 66 69 this.variableImactsArrayView.TabIndex = 2; 67 70 // … … 133 136 this.factorVarReplComboBox.SelectedIndexChanged += new System.EventHandler(this.replacementComboBox_SelectedIndexChanged); 134 137 // 138 // sortByLabel 139 // 140 this.sortByLabel.AutoSize = true; 141 this.sortByLabel.Location = new System.Drawing.Point(324, 6); 142 this.sortByLabel.Name = "sortByLabel"; 143 this.sortByLabel.Size = new System.Drawing.Size(43, 13); 144 this.sortByLabel.TabIndex = 4; 145 this.sortByLabel.Text = "Sort by:"; 146 // 147 // sortByComboBox 148 // 149 this.sortByComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 150 this.sortByComboBox.FormattingEnabled = true; 151 this.sortByComboBox.Items.AddRange(new object[] { 152 "Variable", 153 "Impact"}); 154 this.sortByComboBox.Location = new System.Drawing.Point(373, 3); 155 this.sortByComboBox.Name = "sortByComboBox"; 156 this.sortByComboBox.Size = new System.Drawing.Size(121, 21); 157 this.sortByComboBox.TabIndex = 5; 158 this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged); 159 this.sortByComboBox.SelectedIndex = 1; 160 // 161 // ascendingCheckBox 162 // 163 this.ascendingCheckBox.AutoSize = true; 164 this.ascendingCheckBox.Location = new System.Drawing.Point(500, 6); 165 this.ascendingCheckBox.Name = "ascendingCheckBox"; 166 this.ascendingCheckBox.Size = new System.Drawing.Size(76, 17); 167 this.ascendingCheckBox.TabIndex = 7; 168 this.ascendingCheckBox.Text = "Ascending"; 169 this.ascendingCheckBox.UseVisualStyleBackColor = true; 170 this.ascendingCheckBox.CheckedChanged += new System.EventHandler(this.ascendingCheckBox_CheckedChanged); 171 // 135 172 // RegressionSolutionVariableImpactsView 136 173 // 137 174 this.AllowDrop = true; 138 175 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 176 this.Controls.Add(this.ascendingCheckBox); 177 this.Controls.Add(this.sortByLabel); 178 this.Controls.Add(this.sortByComboBox); 139 179 this.Controls.Add(this.factorVarReplComboBox); 140 180 this.Controls.Add(this.factorVarReplacementLabel); … … 145 185 this.Controls.Add(this.variableImactsArrayView); 146 186 this.Name = "RegressionSolutionVariableImpactsView"; 147 this.Size = new System.Drawing.Size( 369, 365);187 this.Size = new System.Drawing.Size(712, 365); 148 188 this.ResumeLayout(false); 149 189 this.PerformLayout(); … … 160 200 private System.Windows.Forms.Label factorVarReplacementLabel; 161 201 private System.Windows.Forms.ComboBox factorVarReplComboBox; 202 private System.Windows.Forms.Label sortByLabel; 203 private System.Windows.Forms.ComboBox sortByComboBox; 204 private System.Windows.Forms.CheckBox ascendingCheckBox; 162 205 } 163 206 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r15583 r15626 20 20 #endregion 21 21 using System; 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using System.Threading.Tasks; … … 30 31 [Content(typeof(IRegressionSolution))] 31 32 public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 33 34 private const int ORDER_BY_VARIABLE = 0; 35 private const int ORDER_BY_IMPACT = 1; 36 37 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 32 38 33 39 public new IRegressionSolution Content { … … 99 105 impactArray.ElementNames = impacts.Select(i => i.Item1); 100 106 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 107 108 //Remember the original ordering of the variables 109 var problemData = Content.ProblemData; 110 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 111 var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList(); 112 rawVariableImpacts.Clear(); 113 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 114 101 115 } finally { 102 116 mainForm.RemoveOperationProgressFromView(this); … … 105 119 } 106 120 107 #endregion108 109 121 private void dataPartitionComboBox_SelectedIndexChanged(object sender, EventArgs e) { 122 ResetOrdering(); 110 123 UpdateVariableImpacts(); 111 124 } 112 125 113 126 private void replacementComboBox_SelectedIndexChanged(object sender, EventArgs e) { 127 ResetOrdering(); 114 128 UpdateVariableImpacts(); 115 129 } 130 131 private void sortByComboBox_SelectedIndexChanged(object sender, EventArgs e) { 132 UpdateDataOrdering(); 133 } 134 135 private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) { 136 UpdateDataOrdering(); 137 } 138 #endregion 139 140 #region Helper Methods 141 /// <summary> 142 /// Updates the <see cref="variableImactsArrayView"/> according to the selected ordering <see cref="ascendingCheckBox"/> of the selected Column <see cref="sortByComboBox"/> 143 /// The default is "Descending" by "VariableImpact" (as in previous versions) 144 /// </summary> 145 private void UpdateDataOrdering() { 146 int orderIdx = sortByComboBox.SelectedIndex; 147 bool ascending = ascendingCheckBox.Checked; 148 149 //Check if valid ordering is selected AND at if any VariableImpact exists 150 if (orderIdx > -1 && rawVariableImpacts != null && rawVariableImpacts.Any()) { 151 IEnumerable<KeyValuePair<string, double>> orderedEntries = null; 152 153 //Sort accordingly 154 if (orderIdx == ORDER_BY_VARIABLE) { 155 orderedEntries = ascending ? rawVariableImpacts : rawVariableImpacts.Reverse(); 156 } else if (orderIdx == ORDER_BY_IMPACT) { 157 orderedEntries = ascending ? rawVariableImpacts.OrderBy(v => v.Value) : rawVariableImpacts.OrderByDescending(v => v.Value); 158 } 159 160 //Write the data back 161 var impactArray = new DoubleArray(orderedEntries.Select(i => i.Value).ToArray()); 162 impactArray.ElementNames = orderedEntries.Select(i => i.Key); 163 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 164 } 165 } 166 167 /// <summary> 168 /// Resets the ordering to the default behaviour (descending by variableImpact), meaning <see cref="ascendingCheckBox"/> and <see cref="sortByComboBox"/> will be updated 169 /// Note: this will NOT update the UI 170 /// </summary> 171 private void ResetOrdering() { 172 //The events shouldn't fire everytime we reset the data 173 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 174 sortByComboBox.SelectedIndexChanged -= sortByComboBox_SelectedIndexChanged; 175 176 ascendingCheckBox.Checked = false; 177 sortByComboBox.SelectedIndex = ORDER_BY_IMPACT; 178 179 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; 180 sortByComboBox.SelectedIndexChanged += sortByComboBox_SelectedIndexChanged; 181 } 182 #endregion 116 183 } 117 184 }
Note: See TracChangeset
for help on using the changeset viewer.