Changeset 16140 for branches/2817-BinPackingSpeedup/HeuristicLab.DataPreprocessing.Views/3.4/ManipulationView.cs
- Timestamp:
- 09/14/18 11:36:59 (6 years ago)
- Location:
- branches/2817-BinPackingSpeedup
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup
- Property svn:mergeinfo changed
-
branches/2817-BinPackingSpeedup/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
-
branches/2817-BinPackingSpeedup/HeuristicLab.DataPreprocessing.Views/3.4/ManipulationView.cs
r15110 r16140 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Drawing; 25 24 using System.Globalization; … … 44 43 public ManipulationView() { 45 44 InitializeComponent(); 46 cmbReplaceWith.SelectedIndex = 0;47 45 tabsData.Appearance = TabAppearance.FlatButtons; 48 46 tabsData.ItemSize = new Size(0, 1); … … 56 54 () => ValidateDeleteColumnsVariance(), 57 55 () => ValidateDeleteRowsInfo(), 58 () => ValidateReplaceWith(),59 () => ValidateShuffle()60 56 }; 61 57 62 58 manipulations = new Action[] { 63 () => Content.ManipulationLogic.DeleteColumnsWithMissingValuesGreater(GetDeleteColumnsInfo()), 64 () => Content.ManipulationLogic.DeleteColumnsWithVarianceSmaller(GetDeleteColumnsVariance()), 65 () => Content.ManipulationLogic.DeleteRowsWithMissingValuesGreater(GetRowsColumnsInfo()), 66 () => ReplaceMissingValues(), 67 () => Content.ManipulationLogic.Shuffle(shuffleSeparatelyCheckbox.Checked) 59 () => Content.DeleteColumnsWithMissingValuesGreater(GetDeleteColumnsInfo()), 60 () => Content.DeleteColumnsWithVarianceSmaller(GetDeleteColumnsVariance()), 61 () => Content.DeleteRowsWithMissingValuesGreater(GetRowsColumnsInfo()), 68 62 }; 69 63 } … … 72 66 base.OnContentChanged(); 73 67 if (Content != null) { 74 cmbVariableNames.Items.Clear();75 foreach (var name in Content.ManipulationLogic.VariableNames) {76 cmbVariableNames.Items.Add(name);77 }78 cmbVariableNames.SelectedIndex = 0;79 68 CheckFilters(); 80 69 } … … 83 72 protected override void RegisterContentEvents() { 84 73 base.RegisterContentEvents(); 85 Content. FilterLogic.FilterChanged += FilterLogic_FilterChanged;74 Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged; 86 75 } 87 76 88 77 protected override void DeregisterContentEvents() { 89 Content. FilterLogic.FilterChanged -= FilterLogic_FilterChanged;78 Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged; 90 79 base.DeregisterContentEvents(); 91 80 } … … 98 87 99 88 private void CheckFilters() { 100 if (Content. FilterLogic.IsFiltered) {89 if (Content.PreprocessingData.IsFiltered) { 101 90 tabsPreview.SelectedIndex = 0; 102 91 lstMethods.Enabled = false; … … 126 115 } 127 116 128 private void ReplaceMissingValues() {129 var allIndices = Content.SearchLogic.GetMissingValueIndices();130 var columnIndex = cmbVariableNames.SelectedIndex;131 var columnIndices = new Dictionary<int, IList<int>>{132 {columnIndex, allIndices[columnIndex]}133 };134 135 switch (cmbReplaceWith.SelectedIndex) {136 case 0: //Value137 Content.ManipulationLogic.ReplaceIndicesByValue(columnIndices, txtReplaceValue.Text);138 break;139 case 1: //Average140 Content.ManipulationLogic.ReplaceIndicesByAverageValue(columnIndices);141 break;142 case 2: //Median143 Content.ManipulationLogic.ReplaceIndicesByMedianValue(columnIndices);144 break;145 case 3: //Most Common146 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(columnIndices);147 break;148 case 4: //Random149 Content.ManipulationLogic.ReplaceIndicesByRandomValue(columnIndices);150 break;151 }152 }153 154 117 private void ValidateDeleteColumnsInfo() { 155 118 ValidateDoubleTextBox(txtDeleteColumnsInfo.Text); 156 119 if (btnApply.Enabled) { 157 var filteredColumns = Content. ManipulationLogic.ColumnsWithMissingValuesGreater(GetDeleteColumnsInfo());120 var filteredColumns = Content.ColumnsWithMissingValuesGreater(GetDeleteColumnsInfo()); 158 121 int count = filteredColumns.Count; 159 int columnCount = Content. FilterLogic.PreprocessingData.Columns;122 int columnCount = Content.PreprocessingData.Columns; 160 123 lblPreviewColumnsInfo.Text = string.Format("{0} column{1} of {2} ({3}) were detected with more than {4}% missing values.", count, (count > 1 || count == 0 ? "s" : ""), columnCount, string.Format("{0:F2}%", 100d / columnCount * count), txtDeleteColumnsInfo.Text); 161 124 … … 165 128 sb.Append(Environment.NewLine); 166 129 sb.Append("Columns: "); 167 sb.Append(Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));130 sb.Append(Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(0))); 168 131 for (int i = 1; i < filteredColumns.Count; i++) { 169 string columnName = Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));132 string columnName = Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(i)); 170 133 sb.Append(", "); 171 134 sb.Append(columnName); … … 186 149 ValidateDoubleTextBox(txtDeleteColumnsVariance.Text); 187 150 if (btnApply.Enabled) { 188 var filteredColumns = Content. ManipulationLogic.ColumnsWithVarianceSmaller(GetDeleteColumnsVariance());151 var filteredColumns = Content.ColumnsWithVarianceSmaller(GetDeleteColumnsVariance()); 189 152 int count = filteredColumns.Count; 190 int columnCount = Content. FilterLogic.PreprocessingData.Columns;153 int columnCount = Content.PreprocessingData.Columns; 191 154 lblPreviewColumnsVariance.Text = string.Format("{0} column{1} of {2} ({3}) were detected with a variance smaller than {4}.", count, (count > 1 || count == 0 ? "s" : ""), columnCount, string.Format("{0:F2}%", 100d / columnCount * count), txtDeleteColumnsVariance.Text); 192 155 … … 196 159 sb.Append(Environment.NewLine); 197 160 sb.Append("Columns: "); 198 sb.Append(Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));161 sb.Append(Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(0))); 199 162 for (int i = 1; i < filteredColumns.Count; i++) { 200 string columnName = Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));163 string columnName = Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(i)); 201 164 sb.Append(", "); 202 165 sb.Append(columnName); … … 217 180 ValidateDoubleTextBox(txtDeleteRowsInfo.Text); 218 181 if (btnApply.Enabled) { 219 int count = Content. ManipulationLogic.RowsWithMissingValuesGreater(GetRowsColumnsInfo()).Count;220 int rowCount = Content. FilterLogic.PreprocessingData.Rows;182 int count = Content.RowsWithMissingValuesGreater(GetRowsColumnsInfo()).Count; 183 int rowCount = Content.PreprocessingData.Rows; 221 184 lblPreviewRowsInfo.Text = count + " row" + (count > 1 || count == 0 ? "s" : "") + " of " + rowCount + " (" + string.Format("{0:F2}%", 100d / rowCount * count) + ") were detected with more than " + txtDeleteRowsInfo.Text + "% missing values."; 222 185 if (count > 0) { … … 228 191 lblPreviewRowsInfo.Text = "Preview not possible yet - please input the limit above."; 229 192 } 230 }231 232 private void ValidateReplaceWith() {233 btnApply.Enabled = false;234 string replaceWith = (string)cmbReplaceWith.SelectedItem;235 int columnIndex = cmbVariableNames.SelectedIndex;236 237 if (cmbReplaceWith.SelectedIndex == 0) {238 string errorMessage;239 string replaceValue = txtReplaceValue.Text;240 if (string.IsNullOrEmpty(replaceValue)) {241 lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement.";242 } else if (!Content.ManipulationLogic.PreProcessingData.Validate(txtReplaceValue.Text, out errorMessage, columnIndex)) {243 lblPreviewReplaceMissingValues.Text = "Preview not possible yet - " + errorMessage;244 } else {245 btnApply.Enabled = true;246 }247 replaceWith = "\"" + replaceValue + "\"";248 } else {249 btnApply.Enabled = true;250 }251 if (btnApply.Enabled) {252 var allIndices = Content.SearchLogic.GetMissingValueIndices();253 int count = allIndices[columnIndex].Count;254 int cellCount = Content.FilterLogic.PreprocessingData.Rows * Content.FilterLogic.PreprocessingData.Columns;255 lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "")256 + " of " + cellCount + " (" + string.Format("{0:F2}%", 100d / cellCount * count) + ") were detected with missing values which would be replaced with " + replaceWith;257 if (count > 0) {258 lblPreviewReplaceMissingValues.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to perform the replacement.";259 } else {260 btnApply.Enabled = false;261 }262 }263 }264 265 private void ValidateShuffle() {266 btnApply.Enabled = true;267 lblShuffleProperties.Enabled = false;268 lblShuffleProperties.Visible = false;269 shuffleSeparatelyCheckbox.Enabled = true;270 shuffleSeparatelyCheckbox.Visible = true;271 193 } 272 194 … … 295 217 lblPreviewRowsInfo.Text = "rows successfully deleted."; 296 218 break; 297 case 3:298 lblPreviewReplaceMissingValues.Text = "missing values successfully replaced.";299 btnApply.Enabled = false;300 break;301 case 4:302 lblPreviewShuffle.Text = "dataset shuffled successfully.";303 btnApply.Enabled = false;304 break;305 219 } 306 220 } … … 327 241 ValidateDeleteRowsInfo(); 328 242 } 329 330 private void cmbReplaceWith_SelectedIndexChanged(object sender, EventArgs e) {331 bool isReplaceWithValueSelected = cmbReplaceWith.SelectedIndex == 0;332 lblValueColon.Visible = isReplaceWithValueSelected;333 txtReplaceValue.Visible = isReplaceWithValueSelected;334 ValidateReplaceWith();335 }336 337 private void txtReplaceValue_TextChanged(object sender, EventArgs e) {338 ValidateReplaceWith();339 }340 243 } 341 244 }
Note: See TracChangeset
for help on using the changeset viewer.