- Timestamp:
- 10/18/18 16:16:31 (6 years ago)
- Location:
- branches/2915-AbsoluteSymbol
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2915-AbsoluteSymbol
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r15753 r16240 60 60 InitializeComponent(); 61 61 62 //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan.63 62 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray()); 64 63 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; -
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15752 r16240 19 19 */ 20 20 #endregion 21 21 22 22 23 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 81 82 this.sortByComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 82 83 this.sortByComboBox.FormattingEnabled = true; 84 this.sortByComboBox.Items.AddRange(new object[] { 85 HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.ImpactValue, 86 HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.Occurrence, 87 HeuristicLab.Problems.DataAnalysis.Views.RegressionSolutionVariableImpactsView.SortingCriteria.VariableName}); 83 88 this.sortByComboBox.Location = new System.Drawing.Point(407, 3); 84 89 this.sortByComboBox.Name = "sortByComboBox"; … … 159 164 // variableImactsArrayView 160 165 // 161 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 162 | System.Windows.Forms.AnchorStyles.Left) 166 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 167 | System.Windows.Forms.AnchorStyles.Left) 163 168 | System.Windows.Forms.AnchorStyles.Right))); 164 169 this.variableImactsArrayView.Caption = "StringConvertibleArray View"; -
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r15799 r16240 39 39 VariableName 40 40 } 41 private IProgress progress; 42 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 43 42 44 43 public new IRegressionSolution Content { … … 53 52 InitializeComponent(); 54 53 55 //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan.56 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray());57 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;58 59 54 //Set the default values 60 55 this.dataPartitionComboBox.SelectedIndex = 0; 61 this.replacementComboBox.SelectedIndex = 0;56 this.replacementComboBox.SelectedIndex = 3; 62 57 this.factorVarReplComboBox.SelectedIndex = 0; 58 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 63 59 } 64 60 … … 93 89 94 90 private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 95 if (!cancellationToken.IsCancellationRequested) { 96 cancellationToken.Cancel(); 97 } 91 cancellationToken.Cancel(); 98 92 } 99 93 … … 110 104 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) 111 105 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 112 switch ((SortingCriteria)sortByComboBox.SelectedItem) { 113 case SortingCriteria.ImpactValue: 114 ascendingCheckBox.Checked = false; 115 break; 116 case SortingCriteria.Occurrence: 117 ascendingCheckBox.Checked = true; 118 break; 119 case SortingCriteria.VariableName: 120 ascendingCheckBox.Checked = true; 121 break; 122 default: 123 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 124 } 106 ascendingCheckBox.Checked = (SortingCriteria)sortByComboBox.SelectedItem != SortingCriteria.ImpactValue; 125 107 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; 126 108 127 Update DataOrdering();109 UpdateOrdering(); 128 110 } 129 111 130 112 private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) { 131 Update DataOrdering();113 UpdateOrdering(); 132 114 } 133 115 134 116 135 117 private async void UpdateVariableImpact() { 118 IProgress progress; 119 136 120 //Check if the selection is valid 137 121 if (Content == null) { return; } … … 163 147 var problemData = Content.ProblemData; 164 148 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction)); 165 var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList(); 149 var originalVariableOrdering = problemData.Dataset.VariableNames 150 .Where(v => inputvariables.Contains(v)) 151 .Where(v => problemData.Dataset.VariableHasType<double>(v) || problemData.Dataset.VariableHasType<string>(v)) 152 .ToList(); 166 153 167 154 rawVariableImpacts.Clear(); 168 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add( v, impacts.First(vv => vv.Item1 == v).Item2));169 Update DataOrdering();155 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2))); 156 UpdateOrdering(); 170 157 } finally { 171 158 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this); … … 177 164 /// The default is "Descending" by "VariableImpact" (as in previous versions) 178 165 /// </summary> 179 private void Update DataOrdering() {166 private void UpdateOrdering() { 180 167 //Check if valid sortingCriteria is selected and data exists 181 168 if (sortByComboBox.SelectedIndex == -1) { return; } … … 186 173 bool ascending = ascendingCheckBox.Checked; 187 174 188 IEnumerable< KeyValuePair<string, double>> orderedEntries = null;175 IEnumerable<Tuple<string, double>> orderedEntries = null; 189 176 190 177 //Sort accordingly 191 178 switch (selectedItem) { 192 179 case SortingCriteria.ImpactValue: 193 orderedEntries = rawVariableImpacts.OrderBy(v => v. Value);180 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item2); 194 181 break; 195 182 case SortingCriteria.Occurrence: … … 197 184 break; 198 185 case SortingCriteria.VariableName: 199 orderedEntries = rawVariableImpacts.OrderBy(v => v. Key, new NaturalStringComparer());186 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item1, new NaturalStringComparer()); 200 187 break; 201 188 default: … … 206 193 207 194 //Write the data back 208 var impactArray = new DoubleArray(orderedEntries.Select(i => i. Value).ToArray()) {209 ElementNames = orderedEntries.Select(i => i. Key)195 var impactArray = new DoubleArray(orderedEntries.Select(i => i.Item2).ToArray()) { 196 ElementNames = orderedEntries.Select(i => i.Item1) 210 197 }; 211 198
Note: See TracChangeset
for help on using the changeset viewer.