Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/14 12:47:54 (11 years ago)
Author:
sbreuer
Message:
  • selected average and co. implemented
  • SelectionChanged NullPointer fixed
File:
1 edited

Legend:

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

    r10737 r10809  
    4545    }
    4646
    47     public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells) {
    48       preprocessingData.InTransaction(() => {
    49         foreach (var column in cells) {
    50           if (preprocessingData.IsType<double>(column.Key)) {
    51             double average = statisticsLogic.GetAverage(column.Key);
     47    public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     48      preprocessingData.InTransaction(() => {
     49        foreach (var column in cells) {
     50          if (preprocessingData.IsType<double>(column.Key)) {
     51            double average = statisticsLogic.GetAverage(column.Key, considerSelection);
    5252            ReplaceIndicesByValue<double>(column.Key, column.Value, average);
    5353          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    54             DateTime average = statisticsLogic.GetAverageDateTime(column.Key);
     54            DateTime average = statisticsLogic.GetAverageDateTime(column.Key, considerSelection);
    5555            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, average);
    5656          }
     
    5959    }
    6060
    61     public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells) {
    62       preprocessingData.InTransaction(() => {
    63         foreach (var column in cells) {
    64           if (preprocessingData.IsType<double>(column.Key)) {
    65             double median = statisticsLogic.GetMedian(column.Key);
     61    public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     62      preprocessingData.InTransaction(() => {
     63        foreach (var column in cells) {
     64          if (preprocessingData.IsType<double>(column.Key)) {
     65            double median = statisticsLogic.GetMedian(column.Key, considerSelection);
    6666            ReplaceIndicesByValue<double>(column.Key, column.Value, median);
    6767          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    68             DateTime median = statisticsLogic.GetMedianDateTime(column.Key);
     68            DateTime median = statisticsLogic.GetMedianDateTime(column.Key, considerSelection);
    6969            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, median);
    7070          }
     
    7373    }
    7474
    75     public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells) {
     75    public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
    7676      preprocessingData.InTransaction(() => {
    7777        Random r = new Random();
     
    7979        foreach (var column in cells) {
    8080          if (preprocessingData.IsType<double>(column.Key)) {
    81             double max = statisticsLogic.GetMax<double>(column.Key);
    82             double min = statisticsLogic.GetMin<double>(column.Key);
     81            double max = statisticsLogic.GetMax<double>(column.Key, considerSelection);
     82            double min = statisticsLogic.GetMin<double>(column.Key, considerSelection);
    8383            double randMultiplier = (max - min);
    8484            foreach (int index in column.Value) {
     
    8787            }
    8888          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    89             DateTime min = statisticsLogic.GetMin<DateTime>(column.Key);
    90             DateTime max = statisticsLogic.GetMax<DateTime>(column.Key);
     89            DateTime min = statisticsLogic.GetMin<DateTime>(column.Key, considerSelection);
     90            DateTime max = statisticsLogic.GetMax<DateTime>(column.Key, considerSelection);
    9191            double randMultiplier = (max - min).TotalSeconds;
    9292            foreach (int index in column.Value) {
     
    104104          int countValues = 0;
    105105          if (preprocessingData.IsType<double>(column.Key)) {
    106             countValues = preprocessingData.GetValues<double>(column.Key).Count();
    107           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    108             countValues = preprocessingData.GetValues<DateTime>(column.Key).Count();
     106            countValues = preprocessingData.GetValues<double>(column.Key, false).Count();
     107          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     108            countValues = preprocessingData.GetValues<DateTime>(column.Key, false).Count();
    109109          }
    110110
     
    165165    }
    166166
    167     public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells) {
    168       preprocessingData.InTransaction(() => {
    169         foreach (var column in cells) {
    170           if (preprocessingData.IsType<double>(column.Key)) {
    171             ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key));
     167    public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     168      preprocessingData.InTransaction(() => {
     169        foreach (var column in cells) {
     170          if (preprocessingData.IsType<double>(column.Key)) {
     171            ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key, considerSelection));
    172172          } else if (preprocessingData.IsType<string>(column.Key)) {
    173             ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key));
    174           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    175             ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key));
     173            ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key, considerSelection));
     174          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     175            ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key, considerSelection));
    176176          } else {
    177177            throw new ArgumentException("column with index: " + column.Key + " contains a non supported type.");
     
    256256    private void reOrderToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
    257257
    258       List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex));
     258      List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex, false));
    259259
    260260      // process all columns equally
Note: See TracChangeset for help on using the changeset viewer.