Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10737


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

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj

    r10717 r10737  
    243243    </ProjectReference>
    244244  </ItemGroup>
     245  <ItemGroup>
     246    <EmbeddedResource Include="ManipulationView.resx">
     247      <DependentUpon>ManipulationView.cs</DependentUpon>
     248    </EmbeddedResource>
     249  </ItemGroup>
    245250  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    246251  <PropertyGroup>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.Designer.cs

    r10714 r10737  
    4545      this.grpBoxPreview = new System.Windows.Forms.GroupBox();
    4646      this.tabsPreview = new System.Windows.Forms.TabControl();
     47      this.tabPreviewInactive = new System.Windows.Forms.TabPage();
    4748      this.tabPreviewDeleteColumnsInfo = new System.Windows.Forms.TabPage();
     49      this.lblPreviewColumnsInfo = new System.Windows.Forms.Label();
    4850      this.tabPreviewDeleteColumnsVariance = new System.Windows.Forms.TabPage();
     51      this.label12 = new System.Windows.Forms.Label();
     52      this.lblPreviewColumnsVariance = new System.Windows.Forms.Label();
    4953      this.tabPreviewDeleteRowsInfo = new System.Windows.Forms.TabPage();
     54      this.lblPreviewRowsInfo = new System.Windows.Forms.Label();
    5055      this.tabPreviewShuffle = new System.Windows.Forms.TabPage();
    51       this.label9 = new System.Windows.Forms.Label();
    52       this.tabPreviewInactive = new System.Windows.Forms.TabPage();
     56      this.lblPreviewShuffle = new System.Windows.Forms.Label();
    5357      this.grpBoxData.SuspendLayout();
    5458      this.tabsData.SuspendLayout();
     
    6064      this.grpBoxPreview.SuspendLayout();
    6165      this.tabsPreview.SuspendLayout();
     66      this.tabPreviewDeleteColumnsInfo.SuspendLayout();
     67      this.tabPreviewDeleteColumnsVariance.SuspendLayout();
     68      this.tabPreviewDeleteRowsInfo.SuspendLayout();
    6269      this.tabPreviewShuffle.SuspendLayout();
    6370      this.SuspendLayout();
     
    194201      // txtDeleteColumnsVariance
    195202      //
    196       this.txtDeleteColumnsVariance.Location = new System.Drawing.Point(226, 0);
     203      this.txtDeleteColumnsVariance.Location = new System.Drawing.Point(229, 0);
    197204      this.txtDeleteColumnsVariance.Name = "txtDeleteColumnsVariance";
    198205      this.txtDeleteColumnsVariance.Size = new System.Drawing.Size(135, 20);
     
    205212      this.label4.Location = new System.Drawing.Point(3, 3);
    206213      this.label4.Name = "label4";
    207       this.label4.Size = new System.Drawing.Size(217, 13);
     214      this.label4.Size = new System.Drawing.Size(220, 13);
    208215      this.label4.TabIndex = 3;
    209       this.label4.Text = "Delete columns with a variance smaller than ";
     216      this.label4.Text = "Delete columns with a variance smaller than  ";
    210217      //
    211218      // tabDataDeleteRowsInfo
     
    298305      this.tabsPreview.TabIndex = 3;
    299306      //
     307      // tabPreviewInactive
     308      //
     309      this.tabPreviewInactive.Location = new System.Drawing.Point(4, 22);
     310      this.tabPreviewInactive.Name = "tabPreviewInactive";
     311      this.tabPreviewInactive.Padding = new System.Windows.Forms.Padding(3);
     312      this.tabPreviewInactive.Size = new System.Drawing.Size(711, 142);
     313      this.tabPreviewInactive.TabIndex = 5;
     314      this.tabPreviewInactive.Text = "inactive";
     315      this.tabPreviewInactive.UseVisualStyleBackColor = true;
     316      //
    300317      // tabPreviewDeleteColumnsInfo
    301318      //
     319      this.tabPreviewDeleteColumnsInfo.Controls.Add(this.lblPreviewColumnsInfo);
    302320      this.tabPreviewDeleteColumnsInfo.Location = new System.Drawing.Point(4, 22);
    303321      this.tabPreviewDeleteColumnsInfo.Name = "tabPreviewDeleteColumnsInfo";
     
    308326      this.tabPreviewDeleteColumnsInfo.UseVisualStyleBackColor = true;
    309327      //
     328      // lblPreviewColumnsInfo
     329      //
     330      this.lblPreviewColumnsInfo.AutoSize = true;
     331      this.lblPreviewColumnsInfo.Location = new System.Drawing.Point(3, 3);
     332      this.lblPreviewColumnsInfo.Name = "lblPreviewColumnsInfo";
     333      this.lblPreviewColumnsInfo.Size = new System.Drawing.Size(318, 13);
     334      this.lblPreviewColumnsInfo.TabIndex = 1;
     335      this.lblPreviewColumnsInfo.Text = "{0} columns with more than {1} % missing values would be deleted";
     336      //
    310337      // tabPreviewDeleteColumnsVariance
    311338      //
     339      this.tabPreviewDeleteColumnsVariance.Controls.Add(this.label12);
     340      this.tabPreviewDeleteColumnsVariance.Controls.Add(this.lblPreviewColumnsVariance);
    312341      this.tabPreviewDeleteColumnsVariance.Location = new System.Drawing.Point(4, 22);
    313342      this.tabPreviewDeleteColumnsVariance.Name = "tabPreviewDeleteColumnsVariance";
     
    318347      this.tabPreviewDeleteColumnsVariance.UseVisualStyleBackColor = true;
    319348      //
     349      // label12
     350      //
     351      this.label12.AutoSize = true;
     352      this.label12.Location = new System.Drawing.Point(6, 22);
     353      this.label12.Name = "label12";
     354      this.label12.Size = new System.Drawing.Size(0, 13);
     355      this.label12.TabIndex = 2;
     356      //
     357      // lblPreviewColumnsVariance
     358      //
     359      this.lblPreviewColumnsVariance.AutoSize = true;
     360      this.lblPreviewColumnsVariance.Location = new System.Drawing.Point(3, 3);
     361      this.lblPreviewColumnsVariance.Name = "lblPreviewColumnsVariance";
     362      this.lblPreviewColumnsVariance.Size = new System.Drawing.Size(301, 13);
     363      this.lblPreviewColumnsVariance.TabIndex = 2;
     364      this.lblPreviewColumnsVariance.Text = "{0} columns with a variance smaller than {1} would be deleted.";
     365      //
    320366      // tabPreviewDeleteRowsInfo
    321367      //
     368      this.tabPreviewDeleteRowsInfo.Controls.Add(this.lblPreviewRowsInfo);
    322369      this.tabPreviewDeleteRowsInfo.Location = new System.Drawing.Point(4, 22);
    323370      this.tabPreviewDeleteRowsInfo.Name = "tabPreviewDeleteRowsInfo";
     
    328375      this.tabPreviewDeleteRowsInfo.UseVisualStyleBackColor = true;
    329376      //
     377      // lblPreviewRowsInfo
     378      //
     379      this.lblPreviewRowsInfo.AutoSize = true;
     380      this.lblPreviewRowsInfo.Location = new System.Drawing.Point(3, 3);
     381      this.lblPreviewRowsInfo.Name = "lblPreviewRowsInfo";
     382      this.lblPreviewRowsInfo.Size = new System.Drawing.Size(301, 13);
     383      this.lblPreviewRowsInfo.TabIndex = 2;
     384      this.lblPreviewRowsInfo.Text = "{0} rows with more than {1} % missing values would be deleted";
     385      //
    330386      // tabPreviewShuffle
    331387      //
    332       this.tabPreviewShuffle.Controls.Add(this.label9);
     388      this.tabPreviewShuffle.Controls.Add(this.lblPreviewShuffle);
    333389      this.tabPreviewShuffle.Location = new System.Drawing.Point(4, 22);
    334390      this.tabPreviewShuffle.Name = "tabPreviewShuffle";
     
    339395      this.tabPreviewShuffle.UseVisualStyleBackColor = true;
    340396      //
    341       // label9
    342       //
    343       this.label9.AutoSize = true;
    344       this.label9.Location = new System.Drawing.Point(3, 3);
    345       this.label9.Name = "label9";
    346       this.label9.Size = new System.Drawing.Size(252, 13);
    347       this.label9.TabIndex = 0;
    348       this.label9.Text = "Data will be shuffled randomly - preview not possible";
    349       //
    350       // tabPreviewInactive
    351       //
    352       this.tabPreviewInactive.Location = new System.Drawing.Point(4, 22);
    353       this.tabPreviewInactive.Name = "tabPreviewInactive";
    354       this.tabPreviewInactive.Padding = new System.Windows.Forms.Padding(3);
    355       this.tabPreviewInactive.Size = new System.Drawing.Size(711, 142);
    356       this.tabPreviewInactive.TabIndex = 5;
    357       this.tabPreviewInactive.Text = "inactive";
    358       this.tabPreviewInactive.UseVisualStyleBackColor = true;
     397      // lblPreviewShuffle
     398      //
     399      this.lblPreviewShuffle.AutoSize = true;
     400      this.lblPreviewShuffle.Location = new System.Drawing.Point(3, 3);
     401      this.lblPreviewShuffle.Name = "lblPreviewShuffle";
     402      this.lblPreviewShuffle.Size = new System.Drawing.Size(252, 13);
     403      this.lblPreviewShuffle.TabIndex = 0;
     404      this.lblPreviewShuffle.Text = "Data will be shuffled randomly - preview not possible";
    359405      //
    360406      // ManipulationView
     
    382428      this.grpBoxPreview.ResumeLayout(false);
    383429      this.tabsPreview.ResumeLayout(false);
     430      this.tabPreviewDeleteColumnsInfo.ResumeLayout(false);
     431      this.tabPreviewDeleteColumnsInfo.PerformLayout();
     432      this.tabPreviewDeleteColumnsVariance.ResumeLayout(false);
     433      this.tabPreviewDeleteColumnsVariance.PerformLayout();
     434      this.tabPreviewDeleteRowsInfo.ResumeLayout(false);
     435      this.tabPreviewDeleteRowsInfo.PerformLayout();
    384436      this.tabPreviewShuffle.ResumeLayout(false);
    385437      this.tabPreviewShuffle.PerformLayout();
     
    415467    private System.Windows.Forms.TabPage tabPage1;
    416468    private System.Windows.Forms.Label label7;
    417     private System.Windows.Forms.Label label9;
     469    private System.Windows.Forms.Label lblPreviewShuffle;
    418470    private System.Windows.Forms.TabPage tabPreviewInactive;
     471    private System.Windows.Forms.Label lblPreviewColumnsInfo;
     472    private System.Windows.Forms.Label label12;
     473    private System.Windows.Forms.Label lblPreviewColumnsVariance;
     474    private System.Windows.Forms.Label lblPreviewRowsInfo;
    419475  }
    420476}
  • 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  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs

    r10718 r10737  
    299299      List<int> rows= new List<int>();
    300300
    301       for (int i = preprocessingData.Rows - 1; i >= 0; --i)
     301      for (int i = 0; i < preprocessingData.Rows; ++i)
    302302      {
    303303        int missingCount = statisticsLogic.GetRowMissingValueCount(i);
    304         if (100f / preprocessingData.Columns * missingCount >= percent)
     304        if (100f / preprocessingData.Columns * missingCount > percent)
    305305        {
    306306          rows.Add(i);
     
    314314
    315315      List<int> columns = new List<int>();
    316       for (int i = preprocessingData.Columns - 1; i >= 0; --i)
    317       {
     316      for (int i = 0; i < preprocessingData.Columns; ++i) {
    318317        int missingCount = statisticsLogic.GetMissingValueCount(i);
    319         if (100f / preprocessingData.Columns * missingCount >= percent)
    320         {
     318        if (100f / preprocessingData.Rows * missingCount > percent) {
    321319          columns.Add(i);
    322320        }
     
    329327
    330328      List<int> columns = new List<int>();
    331       for (int i = preprocessingData.Columns - 1; i >= 0; --i)
    332       {
     329      for (int i = 0; i < preprocessingData.Columns; ++i) {
    333330        if (preprocessingData.IsType<double>(i) || preprocessingData.IsType<DateTime>(i))
    334331        {
     
    355352    }
    356353
    357     private void DeleteRows(IEnumerable<int> rows) {
     354    private void DeleteRows(List<int> rows) {
     355      rows.Sort();
     356      rows.Reverse();
    358357      preprocessingData.InTransaction(() =>
    359358      {
     
    365364    }
    366365
    367     private void DeleteColumns(IEnumerable<int> columns) {
     366    private void DeleteColumns(List<int> columns) {
     367      columns.Sort();
     368      columns.Reverse();
    368369      preprocessingData.InTransaction(() =>
    369370      {
     
    373374        }
    374375      });
     376    }
     377
     378    public event DataPreprocessingChangedEventHandler Changed {
     379      add { dataGridLogic.Changed += value; }
     380      remove { dataGridLogic.Changed -= value; }
    375381    }
    376382  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/SearchLogic.cs

    r10661 r10737  
    4343    void preprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e)
    4444    {
    45       MissingValueIndicies.Remove(e.Column);
    46       ValuesWithoutNaN.Remove(e.Column);
     45      switch (e.Type) {
     46        case DataPreprocessingChangedEventType.DeleteColumn:
     47        case DataPreprocessingChangedEventType.ChangeColumn:
     48          MissingValueIndicies.Remove(e.Column);
     49          ValuesWithoutNaN.Remove(e.Column);
     50          break;
     51        case DataPreprocessingChangedEventType.AddColumn:
     52          //cache does not need to be updated, will be calculated the first time it is requested
     53          break;
     54        case DataPreprocessingChangedEventType.DeleteRow:
     55        case DataPreprocessingChangedEventType.AddRow:
     56        case DataPreprocessingChangedEventType.ChangeItem:
     57        case DataPreprocessingChangedEventType.Any:
     58        case DataPreprocessingChangedEventType.Transformation:
     59          MissingValueIndicies = new Dictionary<int, IEnumerable<int>>();
     60          ValuesWithoutNaN = new Dictionary<int, IEnumerable>();
     61          break;
     62      }
    4763    }
    4864
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IManipulationLogic.cs

    r10718 r10737  
    4343    void DeleteColumnsWithMissingValuesGreater(double percent);
    4444    void DeleteColumnsWithVarianceSmaller(double variance);
     45
     46    event DataPreprocessingChangedEventHandler Changed;
    4547  }
    4648}
Note: See TracChangeset for help on using the changeset viewer.