Changeset 10809 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs
- Timestamp:
- 05/07/14 12:47:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs
r10737 r10809 45 45 } 46 46 47 public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells ) {48 preprocessingData.InTransaction(() => { 49 foreach (var column in cells) { 50 if (preprocessingData.IsType<double>(column.Key)) { 51 double average = statisticsLogic.GetAverage(column.Key );47 public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection) { 48 preprocessingData.InTransaction(() => { 49 foreach (var column in cells) { 50 if (preprocessingData.IsType<double>(column.Key)) { 51 double average = statisticsLogic.GetAverage(column.Key, considerSelection); 52 52 ReplaceIndicesByValue<double>(column.Key, column.Value, average); 53 53 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 54 DateTime average = statisticsLogic.GetAverageDateTime(column.Key );54 DateTime average = statisticsLogic.GetAverageDateTime(column.Key, considerSelection); 55 55 ReplaceIndicesByValue<DateTime>(column.Key, column.Value, average); 56 56 } … … 59 59 } 60 60 61 public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells ) {62 preprocessingData.InTransaction(() => { 63 foreach (var column in cells) { 64 if (preprocessingData.IsType<double>(column.Key)) { 65 double median = statisticsLogic.GetMedian(column.Key );61 public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection) { 62 preprocessingData.InTransaction(() => { 63 foreach (var column in cells) { 64 if (preprocessingData.IsType<double>(column.Key)) { 65 double median = statisticsLogic.GetMedian(column.Key, considerSelection); 66 66 ReplaceIndicesByValue<double>(column.Key, column.Value, median); 67 67 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 68 DateTime median = statisticsLogic.GetMedianDateTime(column.Key );68 DateTime median = statisticsLogic.GetMedianDateTime(column.Key, considerSelection); 69 69 ReplaceIndicesByValue<DateTime>(column.Key, column.Value, median); 70 70 } … … 73 73 } 74 74 75 public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells ) {75 public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection) { 76 76 preprocessingData.InTransaction(() => { 77 77 Random r = new Random(); … … 79 79 foreach (var column in cells) { 80 80 if (preprocessingData.IsType<double>(column.Key)) { 81 double max = statisticsLogic.GetMax<double>(column.Key );82 double min = statisticsLogic.GetMin<double>(column.Key );81 double max = statisticsLogic.GetMax<double>(column.Key, considerSelection); 82 double min = statisticsLogic.GetMin<double>(column.Key, considerSelection); 83 83 double randMultiplier = (max - min); 84 84 foreach (int index in column.Value) { … … 87 87 } 88 88 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 89 DateTime min = statisticsLogic.GetMin<DateTime>(column.Key );90 DateTime max = statisticsLogic.GetMax<DateTime>(column.Key );89 DateTime min = statisticsLogic.GetMin<DateTime>(column.Key, considerSelection); 90 DateTime max = statisticsLogic.GetMax<DateTime>(column.Key, considerSelection); 91 91 double randMultiplier = (max - min).TotalSeconds; 92 92 foreach (int index in column.Value) { … … 104 104 int countValues = 0; 105 105 if (preprocessingData.IsType<double>(column.Key)) { 106 countValues = preprocessingData.GetValues<double>(column.Key ).Count();107 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 108 countValues = preprocessingData.GetValues<DateTime>(column.Key ).Count();106 countValues = preprocessingData.GetValues<double>(column.Key, false).Count(); 107 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 108 countValues = preprocessingData.GetValues<DateTime>(column.Key, false).Count(); 109 109 } 110 110 … … 165 165 } 166 166 167 public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells ) {168 preprocessingData.InTransaction(() => { 169 foreach (var column in cells) { 170 if (preprocessingData.IsType<double>(column.Key)) { 171 ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key ));167 public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection) { 168 preprocessingData.InTransaction(() => { 169 foreach (var column in cells) { 170 if (preprocessingData.IsType<double>(column.Key)) { 171 ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key, considerSelection)); 172 172 } else if (preprocessingData.IsType<string>(column.Key)) { 173 ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key ));174 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 175 ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key ));173 ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key, considerSelection)); 174 } else if (preprocessingData.IsType<DateTime>(column.Key)) { 175 ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key, considerSelection)); 176 176 } else { 177 177 throw new ArgumentException("column with index: " + column.Key + " contains a non supported type."); … … 256 256 private void reOrderToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) { 257 257 258 List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex ));258 List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex, false)); 259 259 260 260 // process all columns equally
Note: See TracChangeset
for help on using the changeset viewer.