Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/14 14:13:11 (11 years ago)
Author:
rstoll
Message:
  • modified PreprocessingData, uses columnIndex now instead of variableName (is faster and more convenient), set variabelName based methods to Obsolete
  • Already changed SearchLogic, DataGridLogic, StatisticLogic as well as PreprocessingDataManipulation

*

File:
1 edited

Legend:

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

    r10249 r10367  
    3939    public int GetMissingValueCount() {
    4040      int count = 0;
    41       foreach (var variableName in preprocessingData.VariableNames) {
    42         count += GetMissingValueCount(variableName);
     41      for(int i = 0; i < preprocessingData.Columns; ++i){
     42        count += GetMissingValueCount(i);
    4343      }
    4444      return count;
    4545    }
    4646
    47     public int GetMissingValueCount(string variableName) {
    48       return searchLogic.GetMissingValueIndices(variableName).Count();
     47    public int GetMissingValueCount(int columnIndex) {
     48      return searchLogic.GetMissingValueIndices(columnIndex).Count();
    4949    }
    5050
    51     public T GetMin<T>(string variableName) where T : IComparable<T> {
    52       return preprocessingData.GetValues<T>(variableName).Min();
     51    public T GetMin<T>(int columnIndex) where T : IComparable<T> {
     52      return preprocessingData.GetValues<T>(columnIndex).Min();
    5353    }
    5454
    55     public T GetMax<T>(string variableName) where T : IComparable<T> {
    56       return preprocessingData.GetValues<T>(variableName).Max();
     55    public T GetMax<T>(int columnIndex) where T : IComparable<T> {
     56      return preprocessingData.GetValues<T>(columnIndex).Max();
    5757    }
    5858
    59     public double GetMedian(string variableName) {
     59    public double GetMedian(int columnIndex) {
    6060      double median = double.NaN;
    61       if (preprocessingData.IsType<double>(variableName)) {
    62         median = preprocessingData.GetValues<double>(variableName).Median();
     61      if (preprocessingData.IsType<double>(columnIndex)) {
     62        median = preprocessingData.GetValues<double>(columnIndex).Median();
    6363      }
    6464      return median;
    6565    }
    6666
    67     public double GetAverage(string variableName) {
     67    public double GetAverage(int columnIndex) {
    6868      double avg = double.NaN;
    69       if (preprocessingData.IsType<double>(variableName)) {
    70         avg = preprocessingData.GetValues<double>(variableName).Average();
     69      if (preprocessingData.IsType<double>(columnIndex)) {
     70        avg = preprocessingData.GetValues<double>(columnIndex).Average();
    7171      }
    7272      return avg;
    7373    }
    7474
    75     public T GetMostCommonValue<T>(string variableName) {
    76       return preprocessingData.GetValues<T>(variableName)
     75    public T GetMostCommonValue<T>(int columnIndex) {
     76      return preprocessingData.GetValues<T>(columnIndex)
    7777                              .GroupBy(x => x)
    7878                              .OrderByDescending(g => g.Count())
     
    8282
    8383
    84     public double GetStandardDeviation(string variableName) {
     84    public double GetStandardDeviation(int columnIndex) {
    8585      double stdDev = double.NaN;
    86       if (preprocessingData.IsType<double>(variableName)) {
    87         stdDev = preprocessingData.GetValues<double>(variableName).StandardDeviation();
     86      if (preprocessingData.IsType<double>(columnIndex)) {
     87        stdDev = preprocessingData.GetValues<double>(columnIndex).StandardDeviation();
    8888      }
    8989      return stdDev;
    9090    }
    9191
    92     public double GetVariance(string variableName) {
     92    public double GetVariance(int columnIndex) {
    9393      double stdDev = double.NaN;
    94       if (preprocessingData.IsType<double>(variableName)) {
    95         stdDev = preprocessingData.GetValues<double>(variableName).Variance();
     94      if (preprocessingData.IsType<double>(columnIndex)) {
     95        stdDev = preprocessingData.GetValues<double>(columnIndex).Variance();
    9696      }
    9797      return stdDev;
    9898    }
    9999
    100     public int GetDifferentValuesCount<T>(string variableName) {
    101       return preprocessingData.GetValues<T>(variableName).GroupBy(x => x).Count();
     100    public int GetDifferentValuesCount<T>(int columnIndex) {
     101      return preprocessingData.GetValues<T>(columnIndex).GroupBy(x => x).Count();
    102102    }
    103103
    104104    public int GetRowMissingValueCount(int rowIndex) {
    105105      int count = 0;
    106       foreach (var variableName in preprocessingData.VariableNames) {
    107         if (searchLogic.IsMissingValue(variableName, rowIndex)) {
     106       for(int i = 0; i < preprocessingData.Columns; ++i){
     107        if (searchLogic.IsMissingValue(i, rowIndex)) {
    108108          ++count;
    109109        }
     
    111111      return count;
    112112    }
     113
     114
     115    public string GetVariableName(int columnIndex) {
     116      return preprocessingData.GetVariableName(columnIndex);
     117    }
     118
     119    public bool IsType<T>(int columnIndex) {
     120      return preprocessingData.IsType<T>(columnIndex);
     121    }
    113122  }
    114123}
Note: See TracChangeset for help on using the changeset viewer.