Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10809 for branches


Ignore:
Timestamp:
05/07/14 12:47:54 (10 years ago)
Author:
sbreuer
Message:
  • selected average and co. implemented
  • SelectionChanged NullPointer fixed
Location:
branches/DataPreprocessing
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.Designer.cs

    r10768 r10809  
    5454      this.mostCommonToolStripMenuItem_Column = new System.Windows.Forms.ToolStripMenuItem();
    5555      this.interpolationToolStripMenuItem_Column = new System.Windows.Forms.ToolStripMenuItem();
     56      this.smoothingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5657      this.replaceValueOverSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5758      this.averageToolStripMenuItem_Selection = new System.Windows.Forms.ToolStripMenuItem();
     
    5960      this.randomToolStripMenuItem_Selection = new System.Windows.Forms.ToolStripMenuItem();
    6061      this.mostCommonToolStripMenuItem_Selection = new System.Windows.Forms.ToolStripMenuItem();
    61       this.interpolationToolStripMenuItem_Selection = new System.Windows.Forms.ToolStripMenuItem();
    62       this.smoothingToolStripMenuItem_Selection = new System.Windows.Forms.ToolStripMenuItem();
    6362      this.btnSearch = new System.Windows.Forms.Button();
    6463      this.btnReplace = new System.Windows.Forms.Button();
     
    114113            this.randomToolStripMenuItem_Column,
    115114            this.mostCommonToolStripMenuItem_Column,
    116             this.interpolationToolStripMenuItem_Column});
     115            this.interpolationToolStripMenuItem_Column,
     116            this.smoothingToolStripMenuItem});
    117117      this.replaceValueOverColumnToolStripMenuItem.Name = "replaceValueOverColumnToolStripMenuItem";
    118118      this.replaceValueOverColumnToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
     
    154154      this.interpolationToolStripMenuItem_Column.Click += new System.EventHandler(this.ReplaceWithInterpolation_Column_Click);
    155155      //
     156      // smoothingToolStripMenuItem
     157      //
     158      this.smoothingToolStripMenuItem.Name = "smoothingToolStripMenuItem";
     159      this.smoothingToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     160      this.smoothingToolStripMenuItem.Text = "Smoothing";
     161      this.smoothingToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithSmoothing_Selection_Click);
     162      //
    156163      // replaceValueOverSelectionToolStripMenuItem
    157164      //
     
    160167            this.medianToolStripMenuItem_Selection,
    161168            this.randomToolStripMenuItem_Selection,
    162             this.mostCommonToolStripMenuItem_Selection,
    163             this.interpolationToolStripMenuItem_Selection,
    164             this.smoothingToolStripMenuItem_Selection});
     169            this.mostCommonToolStripMenuItem_Selection});
    165170      this.replaceValueOverSelectionToolStripMenuItem.Name = "replaceValueOverSelectionToolStripMenuItem";
    166171      this.replaceValueOverSelectionToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
     
    194199      this.mostCommonToolStripMenuItem_Selection.Text = "Most Common";
    195200      this.mostCommonToolStripMenuItem_Selection.Click += new System.EventHandler(this.ReplaceWithMostCommon_Selection_Click);
    196       //
    197       // interpolationToolStripMenuItem_Selection
    198       //
    199       this.interpolationToolStripMenuItem_Selection.Name = "interpolationToolStripMenuItem_Selection";
    200       this.interpolationToolStripMenuItem_Selection.Size = new System.Drawing.Size(155, 22);
    201       this.interpolationToolStripMenuItem_Selection.Text = "Interpolation";
    202       this.interpolationToolStripMenuItem_Selection.Click += new System.EventHandler(this.ReplaceWithInterpolation_Selection_Click);
    203       //
    204       // smoothingToolStripMenuItem_Selection
    205       //
    206       this.smoothingToolStripMenuItem_Selection.Name = "smoothingToolStripMenuItem_Selection";
    207       this.smoothingToolStripMenuItem_Selection.Size = new System.Drawing.Size(155, 22);
    208       this.smoothingToolStripMenuItem_Selection.Text = "Smoothing";
    209       this.smoothingToolStripMenuItem_Selection.Click += new System.EventHandler(this.ReplaceWithSmoothing_Selection_Click);
    210201      //
    211202      // btnSearch
     
    270261    private System.Windows.Forms.ToolStripMenuItem randomToolStripMenuItem_Selection;
    271262    private System.Windows.Forms.ToolStripMenuItem mostCommonToolStripMenuItem_Selection;
    272     private System.Windows.Forms.ToolStripMenuItem interpolationToolStripMenuItem_Selection;
    273     private System.Windows.Forms.ToolStripMenuItem smoothingToolStripMenuItem_Selection;
    274263    private System.Windows.Forms.Button btnSearch;
    275264    private System.Windows.Forms.Button btnReplace;
    276265    private System.Windows.Forms.ToolTip toolTip;
     266    private System.Windows.Forms.ToolStripMenuItem smoothingToolStripMenuItem;
    277267  }
    278268}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10804 r10809  
    8686
    8787    void DataGridView_SelectionChanged(object sender, EventArgs e) {
    88       Content.DataGridLogic.SetSelection(GetSelectedCells());
     88      if (Content != null) {
     89        Content.DataGridLogic.SetSelection(GetSelectedCells());
     90      }
    8991    }
    9092
     
    150152    private void btnApplySort_Click(object sender, System.EventArgs e) {
    151153      triggersOwnEvent(() => {
    152         Content.PreprocessingDataManipulation.ReOrderToIndices(virtualRowIndices);
     154        Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
    153155        OnContentChanged();
    154156      });
     
    244246        switch (findAndReplaceDialog.GetReplaceAction()) {
    245247          case ReplaceAction.Value:
    246             Content.PreprocessingDataManipulation.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
     248            Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
    247249            break;
    248250          case ReplaceAction.Average:
    249             Content.PreprocessingDataManipulation.ReplaceIndicesByAverageValue(cells);
     251            Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
    250252            break;
    251253          case ReplaceAction.Median:
    252             Content.PreprocessingDataManipulation.ReplaceIndicesByMedianValue(cells);
     254            Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
    253255            break;
    254256          case ReplaceAction.Random:
    255             Content.PreprocessingDataManipulation.ReplaceIndicesByRandomValue(cells);
     257            Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
    256258            break;
    257259          case ReplaceAction.MostCommon:
    258             Content.PreprocessingDataManipulation.ReplaceIndicesByMostCommonValue(cells);
     260            Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
    259261            break;
    260262          case ReplaceAction.Interpolation:
    261             Content.PreprocessingDataManipulation.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
     263            Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
    262264            break;
    263265        }
     
    386388
    387389    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
    388       Content.PreprocessingDataManipulation.ReplaceIndicesByAverageValue(GetSelectedCells());
     390      Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(),false);
     391    }
     392    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
     393      Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
    389394    }
    390395
    391396    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
    392       Content.PreprocessingDataManipulation.ReplaceIndicesByMedianValue(GetSelectedCells());
     397      Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
     398    }
     399    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
     400      Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
    393401    }
    394402
    395403    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
    396       Content.PreprocessingDataManipulation.ReplaceIndicesByRandomValue(GetSelectedCells());
     404      Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
     405    }
     406    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
     407      Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
    397408    }
    398409
    399410    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
    400       Content.PreprocessingDataManipulation.ReplaceIndicesByMostCommonValue(GetSelectedCells());
     411      Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
     412    }
     413    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
     414      Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
    401415    }
    402416
    403417    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
    404       Content.PreprocessingDataManipulation.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
    405     }
    406 
    407     private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
    408     }
    409 
    410     private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
    411     }
    412 
    413     private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
    414     }
    415 
    416     private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
    417     }
    418 
     418      Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
     419    }
    419420    private void ReplaceWithInterpolation_Selection_Click(object sender, EventArgs e) {
     421      Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
    420422    }
    421423
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.cs

    r10776 r10809  
    9191          break;
    9292        case 1: //Average
    93           Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells);
     93          Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
    9494          break;
    9595        case 2: //Median
    96           Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells);
     96          Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
    9797          break;
    9898        case 3: //Most Common
    99           Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells);
     99          Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
    100100          break;
    101101        case 4: //Random
    102           Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells);
     102          Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
    103103          break;
    104104      }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/StatisticsView.cs

    r10742 r10809  
    141141        logic.GetColumnTypeAsString(columnIndex),
    142142        logic.GetMissingValueCount(columnIndex).ToString(),
    143         logic.GetMin<double>(columnIndex).ToString(),
    144         logic.GetMax<double>(columnIndex).ToString(),
    145         logic.GetMedian(columnIndex).ToString(),
    146         logic.GetAverage(columnIndex).ToString(),
     143        logic.GetMin<double>(columnIndex, false).ToString(),
     144        logic.GetMax<double>(columnIndex, false).ToString(),
     145        logic.GetMedian(columnIndex, false).ToString(),
     146        logic.GetAverage(columnIndex, false).ToString(),
    147147        logic.GetStandardDeviation(columnIndex).ToString(),
    148148        logic.GetVariance(columnIndex).ToString(),
    149         logic.GetMostCommonValue<double>(columnIndex).ToString(),
     149        logic.GetMostCommonValue<double>(columnIndex, false).ToString(),
    150150        logic.GetDifferentValuesCount<double>(columnIndex).ToString()
    151151      };
     
    163163        "", //standard deviation
    164164        "", //variance
    165         logic.GetMostCommonValue<string>(columnIndex).ToString(),
     165        logic.GetMostCommonValue<string>(columnIndex, false).ToString(),
    166166        logic.GetDifferentValuesCount<string>(columnIndex).ToString()
    167167      };
     
    173173        logic.GetColumnTypeAsString(columnIndex),
    174174        logic.GetMissingValueCount(columnIndex).ToString(),
    175         logic.GetMin<DateTime>(columnIndex).ToString(),
    176         logic.GetMax<DateTime>(columnIndex).ToString(),
    177         logic.GetMedianDateTime(columnIndex).ToString(),
    178         logic.GetAverageDateTime(columnIndex).ToString(),
     175        logic.GetMin<DateTime>(columnIndex, false).ToString(),
     176        logic.GetMax<DateTime>(columnIndex, false).ToString(),
     177        logic.GetMedianDateTime(columnIndex, false).ToString(),
     178        logic.GetAverageDateTime(columnIndex, false).ToString(),
    179179        logic.GetStandardDeviation(columnIndex).ToString(),
    180180        logic.GetVariance(columnIndex).ToString(), //variance
    181         logic.GetMostCommonValue<DateTime>(columnIndex).ToString(),
     181        logic.GetMostCommonValue<DateTime>(columnIndex, false).ToString(),
    182182        logic.GetDifferentValuesCount<DateTime>(columnIndex).ToString()
    183183      };
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs

    r10803 r10809  
    3737
    3838    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    39       IList<double> values = preprocessingData.GetValues<double>(variableName);
     39      IList<double> values = preprocessingData.GetValues<double>(variableName, false);
    4040      DataRow row = new DataRow(variableName, "", values);
    4141      row.VisualProperties.ChartType = chartType;
     
    4444
    4545    public DataRow CreateDataRowRange(string variableName,int start, int end, DataRowVisualProperties.DataRowChartType chartType) {
    46       IList<double> values = preprocessingData.GetValues<double>(variableName);
     46      IList<double> values = preprocessingData.GetValues<double>(variableName, false);
    4747      IList<double> valuesRange = new List<double>();
    4848      for (int i = 0; i < values.Count; i++) {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridContent.cs

    r10807 r10809  
    4545    }
    4646
    47     public IManipulationLogic PreprocessingDataManipulation {
     47    public IManipulationLogic ManipulationLogic {
    4848      get { return manipulationLogic; }
    4949    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs

    r10804 r10809  
    4141    }
    4242
    43     public IList<T> GetValues<T>(string variableName) {
    44       return ActiveData.GetValues<T>(variableName);
     43    public IList<T> GetValues<T>(string variableName, bool considerSelection) {
     44      return ActiveData.GetValues<T>(variableName, considerSelection);
    4545    }
    4646
    47     public IList<T> GetValues<T>(int columnIndex) {
    48       return ActiveData.GetValues<T>(columnIndex);
     47    public IList<T> GetValues<T>(int columnIndex, bool considerSelection) {
     48      return ActiveData.GetValues<T>(columnIndex, considerSelection);
    4949    }
    5050
  • 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
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10804 r10809  
    122122
    123123    [Obsolete("use the index based variant, is faster")]
    124     public IList<T> GetValues<T>(string variableName) {
    125       return GetValues<T>(GetColumnIndex(variableName));
    126     }
    127 
    128     public IList<T> GetValues<T>(int columnIndex) {
    129       return (IList<T>)variableValues[columnIndex];
     124    public IList<T> GetValues<T>(string variableName, bool considerSelection) {
     125      return GetValues<T>(GetColumnIndex(variableName), considerSelection);
     126    }
     127
     128    public IList<T> GetValues<T>(int columnIndex, bool considerSelection) {
     129      if (considerSelection) {
     130        var list = new List<T>();
     131        foreach (var rowIdx in currentSelection[columnIndex]) {
     132          list.Add((T)variableValues[columnIndex][rowIdx]);
     133        }
     134        return list;
     135      } else {
     136        return (IList<T>)variableValues[columnIndex];
     137      }
    130138    }
    131139
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/SearchLogic.cs

    r10776 r10809  
    3030
    3131    private Dictionary<int, IList<int>> MissingValueIndicies { get; set; }
    32     private Dictionary<int, IEnumerable> ValuesWithoutNaN { get; set; }
     32    private Dictionary<int, IList> ValuesWithoutNaN { get; set; }
    3333
    3434    public SearchLogic(ITransactionalPreprocessingData thePreprocessingData) {
     
    3636
    3737      MissingValueIndicies = new Dictionary<int, IList<int>>();
    38       ValuesWithoutNaN = new Dictionary<int, IEnumerable>();
     38      ValuesWithoutNaN = new Dictionary<int, IList>();
    3939
    4040      preprocessingData.Changed += preprocessingData_Changed;
     
    5858        case DataPreprocessingChangedEventType.Transformation:
    5959          MissingValueIndicies = new Dictionary<int, IList<int>>();
    60           ValuesWithoutNaN = new Dictionary<int, IEnumerable>();
     60          ValuesWithoutNaN = new Dictionary<int, IList>();
    6161          break;
    6262      }
     
    110110    }
    111111
    112     public IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex)
     112    public IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection)
    113113    {
    114       if (!ValuesWithoutNaN.ContainsKey(columnIndex))
    115       {
     114      if (considerSelection) {     
     115        var selectedRows =  preprocessingData.GetSelection()[columnIndex];
     116       
    116117        List<T> values = new List<T>();
    117 
    118         for (int row = 0; row < preprocessingData.Rows; ++row)
    119         {
    120           if (!IsMissingValue(columnIndex, row))
    121           {
    122             values.Add(preprocessingData.GetCell<T>(columnIndex, row));
     118        foreach (var rowIdx in selectedRows) {
     119          if (!IsMissingValue(columnIndex, rowIdx)) {
     120            values.Add(preprocessingData.GetCell<T>(columnIndex, rowIdx));
    123121          }
    124122        }
     123        return values;
     124      } else {
     125        if (!ValuesWithoutNaN.ContainsKey(columnIndex)) {
     126          List<T> values = new List<T>();
    125127
    126         ValuesWithoutNaN[columnIndex] = values;
     128          for (int row = 0; row < preprocessingData.Rows; ++row) {
     129            if (!IsMissingValue(columnIndex, row)) {
     130              values.Add(preprocessingData.GetCell<T>(columnIndex, row));
     131            }
     132          }
     133
     134          ValuesWithoutNaN[columnIndex] = values;
     135        }
     136        return (IEnumerable<T>)ValuesWithoutNaN[columnIndex];
    127137      }
    128 
    129       return (IEnumerable<T>)ValuesWithoutNaN[columnIndex];
    130138    }
    131139  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs

    r10663 r10809  
    7373    }
    7474
    75     public T GetMin<T>(int columnIndex) where T : IComparable<T> {
    76       return preprocessingData.GetValues<T>(columnIndex).Min();
     75    public T GetMin<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     76      return preprocessingData.GetValues<T>(columnIndex, considerSelection).Min();
    7777    }
    7878
    79     public T GetMax<T>(int columnIndex) where T : IComparable<T> {
    80       return preprocessingData.GetValues<T>(columnIndex).Max();
     79    public T GetMax<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     80      return preprocessingData.GetValues<T>(columnIndex, considerSelection).Max();
    8181    }
    8282
    83     public double GetMedian(int columnIndex) {
     83    public double GetMedian(int columnIndex, bool considerSelection) {
    8484      double median = double.NaN;
    8585      if (preprocessingData.IsType<double>(columnIndex)) {
    86         median = GetValuesWithoutNaN<double>(columnIndex).Median();
     86        median = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Median();
    8787      }
    8888      return median;
    8989    }
    9090
    91     public double GetAverage(int columnIndex) {
     91    public double GetAverage(int columnIndex, bool considerSelection) {
    9292      double avg = double.NaN;
    9393      if (preprocessingData.IsType<double>(columnIndex)) {
    94         avg = GetValuesWithoutNaN<double>(columnIndex).Average();
     94        avg = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Average();
    9595      }
    9696      return avg;
    9797    }
    9898
    99     public DateTime GetMedianDateTime(int columnIndex) {
     99    public DateTime GetMedianDateTime(int columnIndex, bool considerSelection) {
    100100      DateTime median = new DateTime();
    101101      if (preprocessingData.IsType<DateTime>(columnIndex)) {
    102         median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex).Median());
     102        median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Median());
    103103      }
    104104      return median;
    105105    }
    106106
    107     public DateTime GetAverageDateTime(int columnIndex) {
     107    public DateTime GetAverageDateTime(int columnIndex, bool considerSelection) {
    108108      DateTime avg = new DateTime();
    109109      if (preprocessingData.IsType<DateTime>(columnIndex)) {
    110         avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex).Average());
     110        avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Average());
    111111      }
    112112      return avg;
    113113    }
    114114
    115     public T GetMostCommonValue<T>(int columnIndex) {
    116       var t = preprocessingData.GetValues<T>(columnIndex);
     115    public T GetMostCommonValue<T>(int columnIndex, bool considerSelection) {
     116      var t = preprocessingData.GetValues<T>(columnIndex, considerSelection);
    117117      var t2 = t.GroupBy(x => x);
    118118      var t3 = t2.Select(g => g.Key);
    119119
    120       return preprocessingData.GetValues<T>(columnIndex)
     120      return preprocessingData.GetValues<T>(columnIndex, considerSelection)
    121121                              .GroupBy(x => x)
    122122                              .OrderByDescending(g => g.Count())
     
    129129      double stdDev = double.NaN;
    130130      if (preprocessingData.IsType<double>(columnIndex)) {
    131         stdDev = GetValuesWithoutNaN<double>(columnIndex).StandardDeviation();
     131        stdDev = GetValuesWithoutNaN<double>(columnIndex, false).StandardDeviation();
    132132      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
    133         stdDev = GetDateTimeAsSeconds(columnIndex).StandardDeviation();
     133        stdDev = GetDateTimeAsSeconds(columnIndex, false).StandardDeviation();
    134134      }
    135135      return stdDev;
     
    139139      double variance = double.NaN;
    140140      if (preprocessingData.IsType<double>(columnIndex)) {
    141         variance = preprocessingData.GetValues<double>(columnIndex).Variance();
     141        variance = preprocessingData.GetValues<double>(columnIndex, false).Variance();
    142142      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
    143         variance = GetDateTimeAsSeconds(columnIndex).Variance();
     143        variance = GetDateTimeAsSeconds(columnIndex, false).Variance();
    144144      }
    145145      return variance;
     
    147147
    148148    public int GetDifferentValuesCount<T>(int columnIndex) {
    149       return preprocessingData.GetValues<T>(columnIndex).GroupBy(x => x).Count();
     149      return preprocessingData.GetValues<T>(columnIndex, false).GroupBy(x => x).Count();
    150150    }
    151151
     
    179179    }
    180180
    181     private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex) {
    182       return GetValuesWithoutNaN<DateTime>(columnIndex).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond);
     181    private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex, bool considerSelection) {
     182      return GetValuesWithoutNaN<DateTime>(columnIndex, considerSelection).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond);
    183183    }
    184184
    185     private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex) {
    186       return searchLogic.GetValuesWithoutNaN<T>(columnIndex);
     185    private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection) {
     186      return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection);
    187187    }
    188188
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridContent.cs

    r10636 r10809  
    2525  public interface IDataGridContent : IStringConvertibleMatrix {
    2626    IDataGridLogic DataGridLogic { get; }
    27     IManipulationLogic PreprocessingDataManipulation { get; }
     27    IManipulationLogic ManipulationLogic { get; }
    2828    IFilterLogic FilterLogic { get; }
    2929
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IManipulationLogic.cs

    r10737 r10809  
    2828    void ReOrderToIndices(IList<Tuple<int, int>> indices);
    2929    void ShuffleToIndices(IList<System.Tuple<int, int>> indices);
    30     void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells);
     30    void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection);
    3131    void ReplaceIndicesByLinearInterpolationOfNeighbours(IDictionary<int, IList<int>> cells);
    32     void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells);
    33     void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells);
    34     void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells);
     32    void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection);
     33    void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection);
     34    void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection);
    3535    void ReplaceIndicesByValue(IDictionary<int, IList<int>> cells, string value);
    3636    void ReplaceIndicesByValue<T>(int columnIndex, IEnumerable<int> rowIndices, T value);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10804 r10809  
    3737
    3838    [Obsolete("use the index based variant, is faster")]
    39     IList<T> GetValues<T>(string variableName);
    40     IList<T> GetValues<T>(int columnIndex);
     39    IList<T> GetValues<T>(string variableName, bool considerSelection);
     40    IList<T> GetValues<T>(int columnIndex, bool considerSelection);
    4141
    4242    void SetValues<T>(int columnIndex, IList<T> values);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/ISearchLogic.cs

    r10776 r10809  
    3939    bool IsMissingValue(int columnIndex, int rowIndex);
    4040
    41     IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex);
     41    IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection);
    4242  }
    4343}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IStatisticsLogic.cs

    r10551 r10809  
    3333    int GetRowMissingValueCount(int rowIndex);
    3434
    35     T GetMin<T>(int columnIndex) where T : IComparable<T>;
    36     T GetMax<T>(int columnIndex) where T : IComparable<T>;
     35    T GetMin<T>(int columnIndex, bool considerSelection) where T : IComparable<T>;
     36    T GetMax<T>(int columnIndex, bool considerSelection) where T : IComparable<T>;
    3737
    38     double GetMedian(int columnIndex);
    39     double GetAverage(int columnIndex);
    40     DateTime GetMedianDateTime(int columnIndex);
    41     DateTime GetAverageDateTime(int columnIndex);
     38    double GetMedian(int columnIndex, bool considerSelection);
     39    double GetAverage(int columnIndex, bool considerSelection);
     40    DateTime GetMedianDateTime(int columnIndex, bool considerSelection);
     41    DateTime GetAverageDateTime(int columnIndex, bool considerSelection);
    4242
    4343    double GetStandardDeviation(int columnIndex);
    4444    double GetVariance(int columnIndex);
    45     T GetMostCommonValue<T>(int columnIndex);
     45    T GetMostCommonValue<T>(int columnIndex, bool considerSelection);
    4646    int GetDifferentValuesCount<T>(int columnIndex);
    4747
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingTransformator.cs

    r10786 r10809  
    5454        int colIndex = preprocessingData.GetColumnIndex(transformation.Column);
    5555
    56         var originalData = preprocessingData.GetValues<double>(colIndex);
     56        var originalData = preprocessingData.GetValues<double>(colIndex, false);
    5757        var transformedData = ApplyDoubleTransformation(transformation, originalData, out success);
    5858        if (!success) return;
Note: See TracChangeset for help on using the changeset viewer.