Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/04/13 14:18:42 (11 years ago)
Author:
rstoll
Message:

Added GetMissingValueIndices to IPreprocessingData since it will be used in many places
Removed columnIndex specific method from PreprocessingData

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10188 r10189  
    149149    }
    150150
     151    public IDictionary<string, IEnumerable<int>> GetMissingValueIndices() {
     152      var dic = new Dictionary<string, IEnumerable<int>>();
     153      foreach (string variableName in VariableNames) {
     154        dic.Add(variableName, GetMissingValueIndices(variableName));
     155      }
     156      return dic;
     157    }
     158
     159    public IEnumerable<int> GetMissingValueIndices(string variableName) {
     160      if (IsType<double>(variableName)) {
     161        return GetValues<double>(variableName).Select((s, i) => new { i, s }).Where(t => double.IsNaN(t.s)).Select(t => t.i);
     162      } else if (IsType<string>(variableName)) {
     163        return GetValues<string>(variableName).Select((s, i) => new { i, s }).Where(t => string.IsNullOrEmpty(t.s)).Select(t => t.i);
     164      } else if (IsType<DateTime>(variableName)) {
     165        return GetValues<DateTime>(variableName).Select((s, i) => new { i, s }).Where(t => t.s.Equals(DateTime.MinValue)).Select(t => t.i);
     166      } else {
     167        throw new ArgumentException("column with index: " + variableName + " contains a non supported type.");
     168      }
     169    }
     170
    151171    #endregion
    152172  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticInfo.cs

    r10183 r10189  
    4343
    4444    public int GetMissingValueCount(string variableName) {
    45       if (preprocessingData.IsType<double>(variableName)) {
    46         return preprocessingData.GetValues<double>(variableName).Count(x => double.IsNaN(x));
    47       } else if (preprocessingData.IsType<string>(variableName)) {
    48         return preprocessingData.GetValues<string>(variableName).Count(x => string.IsNullOrEmpty(x));
    49       } else if (preprocessingData.IsType<DateTime>(variableName)) {
    50         return preprocessingData.GetValues<DateTime>(variableName).Count(x => x.Equals(DateTime.MinValue));
    51       } else {
    52         throw new ArgumentException("column with index: " + variableName + " contains a non supported type.");
    53       }
     45      return preprocessingData.GetMissingValueIndices(variableName).Count();
    5446    }
    5547
Note: See TracChangeset for help on using the changeset viewer.