Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10189


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
Files:
3 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
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10184 r10189  
    4646
    4747    void ExportTo(IDataAnalysisProblemData problemData);
     48
     49    /// <summary>
     50    /// Return the indices of the missing values where the key
     51    /// correspdonds to the variable name and the values to the row indices
     52    /// </summary>
     53    /// <returns></returns>
     54    IDictionary<string, IEnumerable<int>> GetMissingValueIndices();
     55
     56    /// <summary>
     57    /// Return the row indices of the cells which contain a missing value
     58    /// </summary>
     59    /// <returns></returns>
     60    IEnumerable<int> GetMissingValueIndices(string variableName);
    4861  }
    4962}
Note: See TracChangeset for help on using the changeset viewer.