Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/14 13:08:49 (10 years ago)
Author:
rstoll
Message:
  • Preview and execution for delete columns/rows with insufficient information
File:
1 edited

Legend:

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

    r10712 r10737  
    4545
    4646      validators = new Action[] {
    47         ()=>validateDoubleTextBox(txtDeleteColumnsInfo.Text),
    48         ()=>validateDoubleTextBox(txtDeleteColumnsVariance.Text),
    49         ()=>validateDoubleTextBox(txtDeleteRowsInfo.Text),
    50         ()=>{btnApply.Enabled = true;} //shuffle
     47        ()=>validateDeleteColumnsInfo(),
     48        ()=>validateDeleteColumnsVariance(),
     49        ()=>validateDeleteRowsInfo(),
     50        ()=>{btnApply.Enabled = true; lblPreviewShuffle.Text = "Data will be shuffled randomly - preview not possible";} //shuffle
    5151      };
     52
    5253      manipulations = new Action[] {
    53         ()=>{},
    54         ()=>{},
    55         ()=>{},
     54        ()=>Content.ManipulationLogic.DeleteColumnsWithMissingValuesGreater(getDeleteColumnsInfo()),
     55        ()=>Content.ManipulationLogic.DeleteColumnsWithVarianceSmaller(getDeleteColumnsVariance()),
     56        ()=>Content.ManipulationLogic.DeleteRowsWithMissingValuesGreater(getRowsColumnsInfo()),
    5657        ()=>Content.ManipulationLogic.ShuffleWithRanges()
    5758      };
     59    }
     60
     61    protected override void RegisterContentEvents() {
     62      base.RegisterContentEvents();
     63      Content.ManipulationLogic.Changed += Content_Changed;
     64    }
     65
     66    protected override void DeregisterContentEvents() {
     67      base.DeregisterContentEvents();
     68      Content.ManipulationLogic.Changed -= Content_Changed;
     69    }
     70
     71    private double getDeleteColumnsInfo() {
     72      return double.Parse(txtDeleteColumnsInfo.Text);
     73    }
     74
     75    private double getDeleteColumnsVariance() {
     76      return double.Parse(txtDeleteColumnsVariance.Text);
     77    }
     78
     79    private double getRowsColumnsInfo() {
     80      return double.Parse(txtDeleteRowsInfo.Text);
     81    }
     82
     83    private void validateDeleteColumnsInfo() {
     84      validateDoubleTextBox(txtDeleteColumnsInfo.Text);
     85      if (btnApply.Enabled) {
     86        int count = Content.ManipulationLogic.ColumnsWithMissingValuesGreater(getDeleteColumnsInfo()).Count;
     87        lblPreviewColumnsInfo.Text = count + " column" + (count > 1 || count == 0 ? "s" : "") + " were detected with more than " + txtDeleteColumnsInfo.Text + "% missing values.";
     88        if (count > 0) {
     89          lblPreviewColumnsInfo.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those columns.";
     90        } else {
     91          btnApply.Enabled = false;
     92        }
     93      } else {
     94        lblPreviewColumnsInfo.Text = "Preview not possible yet - please input the limit above.";
     95      }
     96    }
     97
     98    private void validateDeleteColumnsVariance() {
     99      validateDoubleTextBox(txtDeleteColumnsVariance.Text);
     100      if (btnApply.Enabled) {
     101        int count = Content.ManipulationLogic.ColumnsWithVarianceSmaller(getDeleteColumnsVariance()).Count;
     102        lblPreviewColumnsVariance.Text = count + " column" + (count > 1 || count == 0 ? "s" : "") + " were detected with a variance smaller than " + txtDeleteColumnsVariance.Text + ".";
     103        if (count > 0) {
     104          lblPreviewColumnsVariance.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those columns.";
     105        } else {
     106          btnApply.Enabled = false;
     107        }
     108      } else {
     109        lblPreviewColumnsVariance.Text = "Preview not possible yet - please input the limit for the variance above.";
     110      }
     111    }
     112
     113    private void validateDeleteRowsInfo() {
     114      validateDoubleTextBox(txtDeleteRowsInfo.Text);
     115      if (btnApply.Enabled) {
     116        int count = Content.ManipulationLogic.RowsWithMissingValuesGreater(getRowsColumnsInfo()).Count;
     117        lblPreviewRowsInfo.Text = count + " row" + (count > 1 || count == 0 ? "s" : "") + " were detected with more than " + txtDeleteRowsInfo.Text + "% missing values.";
     118        if (count > 0) {
     119          lblPreviewRowsInfo.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those rows.";
     120        } else {
     121          btnApply.Enabled = false;
     122        }
     123      } else {
     124        lblPreviewRowsInfo.Text = "Preview not possible yet - please input the limit above.";
     125      }
    58126    }
    59127
     
    70138      btnApply.Enabled = false;
    71139
    72       //in order that button will be enabled if text is already valid
     140      //in order that button is enabled if necessary input was already entered
    73141      if (index >= 0) {
    74142        validators[index]();
     
    78146    private void btnApply_Click(object sender, System.EventArgs e) {
    79147      manipulations[lstMethods.SelectedIndex]();
     148      switch (lstMethods.SelectedIndex) {
     149        case 0:
     150          lblPreviewColumnsInfo.Text = "columns successfully deleted.";
     151          break;
     152        case 1:
     153          lblPreviewColumnsVariance.Text = "columns successfully deleted.";
     154          break;
     155        case 2:
     156          lblPreviewRowsInfo.Text = "rows successfully deleted.";
     157          break;
     158        case 3:
     159          lblPreviewShuffle.Text = "dataset shuffled successfully.";
     160          btnApply.Enabled = false;
     161          break;
     162      }
    80163    }
    81164
     
    91174
    92175    private void txtDeleteColumnsInfo_TextChanged(object sender, EventArgs e) {
    93       validateDoubleTextBox(txtDeleteColumnsInfo.Text);
     176      validateDeleteColumnsInfo();
    94177    }
    95178
    96179    private void txtDeleteColumnsVariance_TextChanged(object sender, EventArgs e) {
    97       validateDoubleTextBox(txtDeleteColumnsVariance.Text);
     180      validateDeleteColumnsVariance();
    98181    }
    99182
    100183    private void txtDeleteRowsInfo_TextChanged(object sender, EventArgs e) {
    101       validateDoubleTextBox(txtDeleteRowsInfo.Text);
     184      validateDeleteRowsInfo();
     185    }
     186
     187    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
     188      switch(lstMethods.SelectedIndex){
     189        case 0:
     190          validateDeleteColumnsInfo();
     191          break;
     192        case 1:
     193          validateDeleteColumnsVariance();
     194          break;
     195        case 2:
     196          validateDeleteRowsInfo();
     197          break;
     198      }
    102199    }
    103200  }
Note: See TracChangeset for help on using the changeset viewer.