Ignore:
Timestamp:
07/09/14 10:37:01 (8 years ago)
Author:
gkronber
Message:

#2206: made several changes / improvements to the data-preprocessing code while reviewing the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationLogic.cs

    r11070 r11156  
    5454      preprocessingData.InTransaction(() => {
    5555        foreach (var column in cells) {
    56           if (preprocessingData.IsType<double>(column.Key)) {
     56          if (preprocessingData.VariableHasType<double>(column.Key)) {
    5757            double average = statisticsLogic.GetAverage(column.Key, considerSelection);
    5858            ReplaceIndicesByValue<double>(column.Key, column.Value, average);
    59           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     59          } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    6060            DateTime average = statisticsLogic.GetAverageDateTime(column.Key, considerSelection);
    6161            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, average);
     
    6868      preprocessingData.InTransaction(() => {
    6969        foreach (var column in cells) {
    70           if (preprocessingData.IsType<double>(column.Key)) {
     70          if (preprocessingData.VariableHasType<double>(column.Key)) {
    7171            double median = statisticsLogic.GetMedian(column.Key, considerSelection);
    7272            ReplaceIndicesByValue<double>(column.Key, column.Value, median);
    73           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     73          } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    7474            DateTime median = statisticsLogic.GetMedianDateTime(column.Key, considerSelection);
    7575            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, median);
     
    8484
    8585        foreach (var column in cells) {
    86           if (preprocessingData.IsType<double>(column.Key)) {
     86          if (preprocessingData.VariableHasType<double>(column.Key)) {
    8787            double max = statisticsLogic.GetMax<double>(column.Key, considerSelection);
    8888            double min = statisticsLogic.GetMin<double>(column.Key, considerSelection);
     
    9292              preprocessingData.SetCell<double>(column.Key, index, rand);
    9393            }
    94           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     94          } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    9595            DateTime min = statisticsLogic.GetMin<DateTime>(column.Key, considerSelection);
    9696            DateTime max = statisticsLogic.GetMax<DateTime>(column.Key, considerSelection);
     
    109109        foreach (var column in cells) {
    110110          int countValues = 0;
    111           if (preprocessingData.IsType<double>(column.Key)) {
     111          if (preprocessingData.VariableHasType<double>(column.Key)) {
    112112            countValues = preprocessingData.GetValues<double>(column.Key).Count();
    113           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     113          } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    114114            countValues = preprocessingData.GetValues<DateTime>(column.Key).Count();
    115115          }
     
    170170      int valuesToInterpolate = nextIndex - prevIndex;
    171171
    172       if (preprocessingData.IsType<double>(column.Key)) {
     172      if (preprocessingData.VariableHasType<double>(column.Key)) {
    173173        double prev = preprocessingData.GetCell<double>(column.Key, prevIndex);
    174174        double next = preprocessingData.GetCell<double>(column.Key, nextIndex);
     
    179179          preprocessingData.SetCell<double>(column.Key, i, interpolated);
    180180        }
    181       } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     181      } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    182182        DateTime prev = preprocessingData.GetCell<DateTime>(column.Key, prevIndex);
    183183        DateTime next = preprocessingData.GetCell<DateTime>(column.Key, nextIndex);
     
    212212      preprocessingData.InTransaction(() => {
    213213        foreach (var column in cells) {
    214           if (preprocessingData.IsType<double>(column.Key)) {
     214          if (preprocessingData.VariableHasType<double>(column.Key)) {
    215215            ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key, considerSelection));
    216           } else if (preprocessingData.IsType<string>(column.Key)) {
     216          } else if (preprocessingData.VariableHasType<string>(column.Key)) {
    217217            ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key, considerSelection));
    218           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     218          } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
    219219            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key, considerSelection));
    220220          } else {
     
    265265      preprocessingData.InTransaction(() => {
    266266        for (int i = 0; i < preprocessingData.Columns; ++i) {
    267           if (preprocessingData.IsType<double>(i)) {
     267          if (preprocessingData.VariableHasType<double>(i)) {
    268268            reOrderToIndices<double>(i, indices);
    269           } else if (preprocessingData.IsType<string>(i)) {
     269          } else if (preprocessingData.VariableHasType<string>(i)) {
    270270            reOrderToIndices<string>(i, indices);
    271           } else if (preprocessingData.IsType<DateTime>(i)) {
     271          } else if (preprocessingData.VariableHasType<DateTime>(i)) {
    272272            reOrderToIndices<DateTime>(i, indices);
    273273          }
     
    279279      preprocessingData.InTransaction(() => {
    280280        for (int i = 0; i < preprocessingData.Columns; ++i) {
    281           if (preprocessingData.IsType<double>(i)) {
     281          if (preprocessingData.VariableHasType<double>(i)) {
    282282            ShuffleToIndices<double>(i, indices);
    283           } else if (preprocessingData.IsType<string>(i)) {
     283          } else if (preprocessingData.VariableHasType<string>(i)) {
    284284            ShuffleToIndices<string>(i, indices);
    285           } else if (preprocessingData.IsType<DateTime>(i)) {
     285          } else if (preprocessingData.VariableHasType<DateTime>(i)) {
    286286            ShuffleToIndices<DateTime>(i, indices);
    287287          }
     
    360360      List<int> columns = new List<int>();
    361361      for (int i = 0; i < preprocessingData.Columns; ++i) {
    362         if (preprocessingData.IsType<double>(i) || preprocessingData.IsType<DateTime>(i)) {
     362        if (preprocessingData.VariableHasType<double>(i) || preprocessingData.VariableHasType<DateTime>(i)) {
    363363          double columnVariance = statisticsLogic.GetVariance(i);
    364364          if (columnVariance < variance) {
Note: See TracChangeset for help on using the changeset viewer.