Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/16 22:39:50 (8 years ago)
Author:
mkommend
Message:

#2393: Merged r13838 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing/3.4

  • stable/HeuristicLab.DataPreprocessing/3.4/Logic/SearchLogic.cs

    r13508 r14076  
    9393    }
    9494
     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
    95127    public bool IsMissingValue(int columnIndex, int rowIndex) {
    96128      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    103135        throw new ArgumentException("cell in column " + columnIndex + " and row index " + rowIndex + " contains a non supported type.");
    104136      }
    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;
    132137    }
    133138
Note: See TracChangeset for help on using the changeset viewer.