Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/14 14:37:39 (10 years ago)
Author:
rstoll
Message:
  • Manipulation View

missing values per column
validating per column
success message for missing values was missing

File:
1 edited

Legend:

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

    r10811 r10905  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Windows.Forms;
     
    6061        ()=>Content.ManipulationLogic.ShuffleWithRanges()
    6162      };
     63
     64    }
     65
     66    protected override void OnContentChanged() {
     67      base.OnContentChanged();
     68      if (Content != null) {
     69        cmbVariableNames.Items.Clear();
     70        foreach (var name in Content.DataGridLogic.ColumnNames) {
     71          cmbVariableNames.Items.Add(name);
     72        }
     73        cmbVariableNames.SelectedIndex = 0;
     74      }
    6275    }
    6376
     
    8598
    8699    private void replaceMissingValues() {
    87       var cells = Content.SearchLogic.GetMissingValueIndices();
    88       switch (cmbReplaceWith.SelectedIndex) {
     100      var allIndices = Content.SearchLogic.GetMissingValueIndices();
     101      var columnIndex = cmbVariableNames.SelectedIndex;
     102      var columnIndices = new Dictionary<int, IList<int>>{
     103          {columnIndex,   allIndices[columnIndex]}
     104      };
     105
     106      switch (cmbReplaceWith.SelectedIndex) {
    89107        case 0: //Value
    90           Content.ManipulationLogic.ReplaceIndicesByValue(cells, txtReplaceValue.Text);
     108          Content.ManipulationLogic.ReplaceIndicesByValue(columnIndices, txtReplaceValue.Text);
    91109          break;
    92110        case 1: //Average
    93           Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells);
     111          Content.ManipulationLogic.ReplaceIndicesByAverageValue(columnIndices);
    94112          break;
    95113        case 2: //Median
    96           Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells);
     114          Content.ManipulationLogic.ReplaceIndicesByMedianValue(columnIndices);
    97115          break;
    98116        case 3: //Most Common
    99           Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells);
     117          Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(columnIndices);
    100118          break;
    101119        case 4: //Random
    102           Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells);
     120          Content.ManipulationLogic.ReplaceIndicesByRandomValue(columnIndices);
    103121          break;
    104122      }
     
    152170    private void validateReplaceWith() {
    153171      btnApply.Enabled = false;
    154       string replaceValue = cmbReplaceWith.SelectedText;
     172      string replaceWith = (string)cmbReplaceWith.SelectedItem;
     173      int columnIndex = cmbVariableNames.SelectedIndex;
     174
    155175      if (cmbReplaceWith.SelectedIndex == 0) {
    156         btnApply.Enabled = !string.IsNullOrEmpty(txtReplaceValue.Text);
    157         replaceValue = @"\"+ txtReplaceValue.Text + @"\";
     176        string errorMessage;
     177        string replaceValue = txtReplaceValue.Text;
     178        if (string.IsNullOrEmpty(replaceValue)) {
     179          lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement.";
     180        } else if (!Content.DataGridLogic.Validate(txtReplaceValue.Text, out errorMessage, columnIndex)) {
     181          lblPreviewReplaceMissingValues.Text = "Preview not possible yet - " + errorMessage;
     182        } else {
     183          btnApply.Enabled = true;
     184        }
     185        replaceWith = "\"" + replaceValue + "\"";
    158186      } else {
    159187        btnApply.Enabled = true;
    160188      }
    161189      if (btnApply.Enabled) {
    162         int count = Content.SearchLogic.GetMissingValueIndices().Count;
    163         lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "")
    164           + " were detected with missing values which would be replaced with " + replaceValue;
     190        var allIndices = Content.SearchLogic.GetMissingValueIndices();
     191        int count = allIndices[columnIndex].Count;
     192        lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "")
     193          + " were detected with missing values which would be replaced with " + replaceWith;
    165194        if (count > 0) {
    166195          lblPreviewReplaceMissingValues.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to perform the replacement.";
     
    168197          btnApply.Enabled = false;
    169198        }
    170       } else {
    171         lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement.";
    172199      }
    173200    }
     
    203230          break;
    204231        case 3:
     232          lblPreviewReplaceMissingValues.Text = "missing values successfully replaced.";
     233          btnApply.Enabled = false;
     234          break;
     235        case 4:
    205236          lblPreviewShuffle.Text = "dataset shuffled successfully.";
    206237          btnApply.Enabled = false;
     
    232263
    233264    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    234       switch(lstMethods.SelectedIndex){
     265      switch (lstMethods.SelectedIndex) {
    235266        case 0:
    236267          validateDeleteColumnsInfo();
Note: See TracChangeset for help on using the changeset viewer.