Changeset 13838 for trunk/sources/HeuristicLab.DataPreprocessing
- Timestamp:
- 05/09/16 13:47:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/SearchLogic.cs
r13508 r13838 93 93 } 94 94 95 public IList<int> GetMissingValueIndices(int columnIndex) { 96 int index = 0; 97 var indices = new List<int>(); 98 99 if (MissingValueIndicies.ContainsKey(columnIndex)) { 100 return MissingValueIndicies[columnIndex]; 101 } 102 103 if (preprocessingData.VariableHasType<double>(columnIndex)) { 104 foreach (var v in preprocessingData.GetValues<double>(columnIndex)) { 105 if (double.IsNaN(v)) indices.Add(index); 106 index++; 107 } 108 } else if (preprocessingData.VariableHasType<string>(columnIndex)) { 109 foreach (var v in preprocessingData.GetValues<string>(columnIndex)) { 110 if (string.IsNullOrEmpty(v)) indices.Add(index); 111 index++; 112 } 113 } else if (preprocessingData.VariableHasType<DateTime>(columnIndex)) { 114 foreach (var v in preprocessingData.GetValues<DateTime>(columnIndex)) { 115 if (DateTime.MinValue.Equals(v)) indices.Add(index); 116 index++; 117 } 118 } else { 119 throw new ArgumentException("column " + columnIndex + " contains a non supported type."); 120 } 121 122 MissingValueIndicies[columnIndex] = indices; 123 return MissingValueIndicies[columnIndex]; 124 } 125 126 95 127 public bool IsMissingValue(int columnIndex, int rowIndex) { 96 128 if (preprocessingData.VariableHasType<double>(columnIndex)) { … … 103 135 throw new ArgumentException("cell in column " + columnIndex + " and row index " + rowIndex + " contains a non supported type."); 104 136 } 105 }106 107 public IList<int> GetMissingValueIndices(int columnIndex) {108 if (!MissingValueIndicies.ContainsKey(columnIndex)) {109 if (preprocessingData.VariableHasType<double>(columnIndex)) {110 MissingValueIndicies[columnIndex] = GetMissingValueIndices<double>(columnIndex);111 } else if (preprocessingData.VariableHasType<string>(columnIndex)) {112 MissingValueIndicies[columnIndex] = GetMissingValueIndices<string>(columnIndex);113 } else if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {114 MissingValueIndicies[columnIndex] = GetMissingValueIndices<DateTime>(columnIndex);115 } else {116 throw new ArgumentException("column " + columnIndex + " contains a non supported type.");117 }118 }119 return MissingValueIndicies[columnIndex];120 }121 122 private IList<int> GetMissingValueIndices<T>(int columnIndex) {123 List<int> missingIndices = new List<int>();124 125 for (int row = 0; row < preprocessingData.Rows; ++row) {126 if (IsMissingValue(columnIndex, row)) {127 missingIndices.Add(row);128 }129 }130 131 return missingIndices;132 137 } 133 138
Note: See TracChangeset
for help on using the changeset viewer.