Changeset 15269
- Timestamp:
- 07/18/17 14:19:29 (7 years ago)
- Location:
- branches/DataPreprocessing Cleanup
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs
r15110 r15269 52 52 53 53 private void InitData() { 54 IDictionary<int, IList<int>> missingValueIndices = Content.SearchLogic.GetMissingValueIndices(); 55 56 bool[,] valueMissing = new bool[Content.SearchLogic.Rows, Content.SearchLogic.Columns]; 57 foreach (var columnMissingValues in missingValueIndices) { 58 var column = columnMissingValues.Key; 59 foreach (var missingValueIndex in columnMissingValues.Value) 60 valueMissing[missingValueIndex, column] = true; 54 bool[,] valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns]; 55 for (int row = 0; row < Content.PreprocessingData.Rows; row++) { 56 for (int column = 0; column < Content.PreprocessingData.Columns; column++) 57 valueMissing[row, column] = Content.PreprocessingData.IsCellEmpty(column, row); 61 58 } 62 59 … … 78 75 //custom x axis label 79 76 double from = 0.5; 80 foreach (String columnName in Content. SearchLogic.VariableNames) {77 foreach (String columnName in Content.PreprocessingData.VariableNames) { 81 78 double to = from + 1; 82 79 chart.ChartAreas[0].AxisX.CustomLabels.Add(from, to, columnName); -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs
r15185 r15269 50 50 var data = Content.Data; 51 51 var filterLogic = new FilterLogic(data); 52 var searchLogic = new SearchLogic(data, filterLogic); 53 var statisticsLogic = new StatisticsLogic(data, searchLogic); 54 var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic); 52 var statisticsLogic = new StatisticsLogic(data); 53 var manipulationLogic = new ManipulationLogic(data, statisticsLogic); 55 54 56 55 var viewShortcuts = new ItemList<IViewShortcut> { … … 63 62 new MultiScatterPlotContent(data), 64 63 new CorrelationMatrixContent(Content), 65 new DataCompletenessChartContent( searchLogic),64 new DataCompletenessChartContent(data), 66 65 67 66 new FilterContent(filterLogic), 68 new ManipulationContent(manipulationLogic, searchLogic,filterLogic),67 new ManipulationContent(manipulationLogic, filterLogic), 69 68 new TransformationContent(data, filterLogic) 70 69 }; -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/ManipulationView.cs
r15110 r15269 127 127 128 128 private void ReplaceMissingValues() { 129 var allIndices = Content.SearchLogic.GetMissingValueIndices();129 var missingValuesIndices = new List<int>(); 130 130 var columnIndex = cmbVariableNames.SelectedIndex; 131 var columnIndices = new Dictionary<int, IList<int>>{ 132 {columnIndex, allIndices[columnIndex]} 133 }; 131 var columnIndices = new Dictionary<int, IList<int>> { { columnIndex, missingValuesIndices } }; 132 133 for (int rowIndex = 0; rowIndex < Content.ManipulationLogic.PreProcessingData.Rows; rowIndex++) 134 if (Content.ManipulationLogic.PreProcessingData.IsCellEmpty(columnIndex, rowIndex)) 135 missingValuesIndices.Add(rowIndex); 134 136 135 137 switch (cmbReplaceWith.SelectedIndex) { … … 165 167 sb.Append(Environment.NewLine); 166 168 sb.Append("Columns: "); 167 sb.Append(Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));169 sb.Append(Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0))); 168 170 for (int i = 1; i < filteredColumns.Count; i++) { 169 string columnName = Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));171 string columnName = Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i)); 170 172 sb.Append(", "); 171 173 sb.Append(columnName); … … 196 198 sb.Append(Environment.NewLine); 197 199 sb.Append("Columns: "); 198 sb.Append(Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));200 sb.Append(Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0))); 199 201 for (int i = 1; i < filteredColumns.Count; i++) { 200 string columnName = Content. SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));202 string columnName = Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i)); 201 203 sb.Append(", "); 202 204 sb.Append(columnName); … … 250 252 } 251 253 if (btnApply.Enabled) { 252 var allIndices = Content.SearchLogic.GetMissingValueIndices(); 253 int count = allIndices[columnIndex].Count; 254 int count = 0; 255 for (int rowIndex = 0; rowIndex < Content.ManipulationLogic.PreProcessingData.Rows; rowIndex++) 256 if (Content.ManipulationLogic.PreProcessingData.IsCellEmpty(columnIndex, rowIndex)) count++; 257 254 258 int cellCount = Content.FilterLogic.PreprocessingData.Rows * Content.FilterLogic.PreprocessingData.Columns; 255 259 lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "") -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/ViewShortcutListView.cs
r15110 r15269 42 42 //Clone chart items 43 43 protected override void itemsListView_DoubleClick(object sender, EventArgs e) { 44 if (itemsListView.SelectedItems.Count == 1) { 45 IViewShortcut item = itemsListView.SelectedItems[0].Tag as IViewShortcut; 46 if (item != null) { 47 try { 48 item = (IViewShortcut)item.Clone(); 49 var view = MainFormManager.MainForm.ShowContent(item); 50 if (view != null) { 51 view.ReadOnly = ReadOnly; 52 view.Locked = Locked; 53 } 54 } catch (NullReferenceException) { 55 // cloning for preprocessing not done properly yet 56 } 44 if (itemsListView.SelectedItems.Count != 1) return; 45 IViewShortcut item = itemsListView.SelectedItems[0].Tag as IViewShortcut; 46 if (item == null) return; 47 try { 48 item = (IViewShortcut)item.Clone(); 49 var view = MainFormManager.MainForm.ShowContent(item); 50 if (view != null) { 51 view.ReadOnly = ReadOnly; 52 view.Locked = Locked; 57 53 } 54 } catch (NullReferenceException) { 55 // cloning for preprocessing not done properly yet 58 56 } 59 57 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs
r15110 r15269 32 32 } 33 33 34 public SearchLogic SearchLogic{ get; private set; }34 public ITransactionalPreprocessingData PreprocessingData { get; private set; } 35 35 36 public DataCompletenessChartContent( SearchLogic searchLogic) {37 SearchLogic = searchLogic;36 public DataCompletenessChartContent(ITransactionalPreprocessingData preprocessingData) { 37 PreprocessingData = preprocessingData; 38 38 } 39 39 40 40 public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner) 41 41 : base(content, cloner) { 42 SearchLogic = content.SearchLogic;42 PreprocessingData = content.PreprocessingData; 43 43 } 44 44 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs
r15110 r15269 33 33 34 34 public ManipulationLogic ManipulationLogic { get; private set; } 35 public SearchLogic SearchLogic { get; private set; }36 35 public FilterLogic FilterLogic { get; private set; } 37 36 38 public ManipulationContent(ManipulationLogic manipulationLogic, SearchLogic searchLogic,FilterLogic filterLogic) {37 public ManipulationContent(ManipulationLogic manipulationLogic, FilterLogic filterLogic) { 39 38 ManipulationLogic = manipulationLogic; 40 SearchLogic = searchLogic;41 39 FilterLogic = filterLogic; 42 40 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs
r15110 r15269 28 28 29 29 namespace HeuristicLab.DataPreprocessing { 30 public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {30 public sealed class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData { 31 31 private readonly ITransactionalPreprocessingData originalData; 32 32 private ITransactionalPreprocessingData filteredData; … … 83 83 } 84 84 85 pr otectedFilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)85 private FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner) 86 86 : base(original, cloner) { 87 87 originalData = original.originalData; … … 90 90 public override IDeepCloneable Clone(Cloner cloner) { 91 91 return new FilteredPreprocessingData(this, cloner); 92 } 93 94 public bool IsCellEmpty(int columnIndex, int rowIndex) { 95 return ActiveData.IsCellEmpty(columnIndex, rowIndex); 92 96 } 93 97 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs
r15110 r15269 28 28 namespace HeuristicLab.DataPreprocessing { 29 29 public interface IPreprocessingData : INamedItem { 30 bool IsCellEmpty(int columnIndex, int rowIndex); 30 31 T GetCell<T>(int columnIndex, int rowIndex); 31 32 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs
r15110 r15269 160 160 } 161 161 162 public static bool IsMissingValue(object value) { 163 if (value is double) return double.IsNaN((double)value); 164 if (value is string) return string.IsNullOrEmpty((string)value); 165 if (value is DateTime) return ((DateTime)value).Equals(DateTime.MinValue); 166 throw new ArgumentException(); 167 } 162 168 163 169 #region IPreprocessingData Members 170 public abstract bool IsCellEmpty(int columnIndex, int rowIndex); 164 171 public abstract T GetCell<T>(int columnIndex, int rowIndex); 165 172 … … 173 180 174 181 public abstract bool VariableHasType<T>(int columnIndex); 175 176 [Obsolete("use the index based variant, is faster")]177 public abstract IList<T> GetValues<T>(string variableName, bool considerSelection);178 182 179 183 public abstract IList<T> GetValues<T>(int columnIndex, bool considerSelection); -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/TransactionalPreprocessingData.cs
r15110 r15269 88 88 89 89 #region Overridden IPreprocessingData Members 90 public override bool IsCellEmpty(int columnIndex, int rowIndex) { 91 var value = variableValues[columnIndex][rowIndex]; 92 return IsMissingValue(value); 93 } 94 90 95 public override T GetCell<T>(int columnIndex, int rowIndex) { 91 96 return (T)variableValues[columnIndex][rowIndex]; … … 119 124 public override bool VariableHasType<T>(int columnIndex) { 120 125 return columnIndex >= variableValues.Count || variableValues[columnIndex] is List<T>; 121 }122 123 [Obsolete("use the index based variant, is faster")]124 public override IList<T> GetValues<T>(string variableName, bool considerSelection) {125 return GetValues<T>(GetColumnIndex(variableName), considerSelection);126 126 } 127 127 -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r15268 r15269 146 146 <Compile Include="PreprocessingContext.cs" /> 147 147 <Compile Include="Data\TransactionalPreprocessingData.cs" /> 148 <Compile Include="Logic\SearchLogic.cs" />149 148 <Compile Include="Logic\StatisticsLogic.cs" /> 150 149 <Compile Include="Data\ITransactionalPreprocessingData.cs" /> -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs
r15110 r15269 73 73 } 74 74 75 p ublicbool Result(bool current, bool addition, bool isAndCombination) {75 private bool Result(bool current, bool addition, bool isAndCombination) { 76 76 return isAndCombination ? current || addition : current && addition; 77 77 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs
r15110 r15269 30 30 private readonly ITransactionalPreprocessingData preprocessingData; 31 31 private readonly StatisticsLogic statisticsLogic; 32 private readonly SearchLogic searchLogic;33 32 34 33 public IEnumerable<string> VariableNames { … … 40 39 } 41 40 42 public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, S earchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {41 public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, StatisticsLogic theStatisticsLogic) { 43 42 this.preprocessingData = preprocessingData; 44 searchLogic = theSearchLogic;45 43 statisticsLogic = theStatisticsLogic; 46 44 } … … 187 185 private int indexOfPrevPresentValue(int columnIndex, int start) { 188 186 int offset = start - 1; 189 while (offset >= 0 && searchLogic.IsMissingValue(columnIndex, offset)) {187 while (offset >= 0 && preprocessingData.IsCellEmpty(columnIndex, offset)) { 190 188 offset--; 191 189 } … … 196 194 private int indexOfNextPresentValue(int columnIndex, int start) { 197 195 int offset = start + 1; 198 while (offset < preprocessingData.Rows && searchLogic.IsMissingValue(columnIndex, offset)) {196 while (offset < preprocessingData.Rows && preprocessingData.IsCellEmpty(columnIndex, offset)) { 199 197 offset++; 200 198 } -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs
r15110 r15269 28 28 public class StatisticsLogic { 29 29 private readonly ITransactionalPreprocessingData preprocessingData; 30 private readonly SearchLogic searchLogic; 31 32 public StatisticsLogic(ITransactionalPreprocessingData thePreprocessingData, SearchLogic theSearchLogic) { 33 preprocessingData = thePreprocessingData; 34 searchLogic = theSearchLogic; 30 31 public StatisticsLogic(ITransactionalPreprocessingData preprocessingData) { 32 this.preprocessingData = preprocessingData; 35 33 } 36 34 37 35 public int GetColumnCount() { 38 return searchLogic.Columns;36 return preprocessingData.Columns; 39 37 } 40 38 41 39 public int GetRowCount() { 42 return searchLogic.Rows;40 return preprocessingData.Rows; 43 41 } 44 42 … … 46 44 int count = 0; 47 45 48 for (int i = 0; i < searchLogic.Columns; ++i) {46 for (int i = 0; i < preprocessingData.Columns; ++i) { 49 47 if (preprocessingData.VariableHasType<double>(i)) { 50 48 ++count; … … 55 53 56 54 public int GetNominalColumnCount() { 57 return searchLogic.Columns - GetNumericColumnCount();55 return preprocessingData.Columns - GetNumericColumnCount(); 58 56 } 59 57 60 58 public int GetMissingValueCount() { 61 59 int count = 0; 62 for (int i = 0; i < searchLogic.Columns; ++i) {60 for (int i = 0; i < preprocessingData.Columns; ++i) { 63 61 count += GetMissingValueCount(i); 64 62 } … … 67 65 68 66 public int GetMissingValueCount(int columnIndex) { 69 return searchLogic.GetMissingValueIndices(columnIndex).Count(); 67 return Enumerable.Range(0, preprocessingData.Rows).Count(rowIndex => preprocessingData.IsCellEmpty(columnIndex, rowIndex)); 68 } 69 70 public int GetRowMissingValueCount(int rowIndex) { 71 var columnIndexes = Enumerable.Range(0, preprocessingData.Columns); 72 return columnIndexes.Count(columnIndex => !preprocessingData.IsCellEmpty(columnIndex, rowIndex)); 73 } 74 75 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) { 76 return preprocessingData.GetValues<T>(columnIndex, considerSelection).Where(x => !PreprocessingData.IsMissingValue(x)).ToList(); 70 77 } 71 78 … … 185 192 } 186 193 187 public int GetRowMissingValueCount(int rowIndex) { 188 int count = 0; 189 for (int i = 0; i < preprocessingData.Columns; ++i) { 190 if (searchLogic.IsMissingValue(i, rowIndex)) { 191 ++count; 192 } 193 } 194 return count; 195 } 196 197 public string GetVariableName(int columnIndex) { 198 return preprocessingData.GetVariableName(columnIndex); 199 } 194 200 195 201 196 public bool VariableHasType<T>(int columnIndex) { … … 218 213 } 219 214 220 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) {221 return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection);222 }223 215 224 216 private DateTime GetSecondsAsDateTime(double seconds) {
Note: See TracChangeset
for help on using the changeset viewer.