Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 11:54:35 (5 years ago)
Author:
pfleck
Message:

#2845 Merged trunk changes before source move into branch

Location:
branches/2845_EnhancedProgress
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress

  • branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views

  • branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/ManipulationView.cs

    r15110 r16307  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Drawing;
    2524using System.Globalization;
     
    4443    public ManipulationView() {
    4544      InitializeComponent();
    46       cmbReplaceWith.SelectedIndex = 0;
    4745      tabsData.Appearance = TabAppearance.FlatButtons;
    4846      tabsData.ItemSize = new Size(0, 1);
     
    5654        () => ValidateDeleteColumnsVariance(),
    5755        () => ValidateDeleteRowsInfo(),
    58         () => ValidateReplaceWith(),
    59         () => ValidateShuffle()
    6056      };
    6157
    6258      manipulations = new Action[] {
    63         () => Content.ManipulationLogic.DeleteColumnsWithMissingValuesGreater(GetDeleteColumnsInfo()),
    64         () => Content.ManipulationLogic.DeleteColumnsWithVarianceSmaller(GetDeleteColumnsVariance()),
    65         () => Content.ManipulationLogic.DeleteRowsWithMissingValuesGreater(GetRowsColumnsInfo()),
    66         () => ReplaceMissingValues(),
    67         () => Content.ManipulationLogic.Shuffle(shuffleSeparatelyCheckbox.Checked)
     59        () => Content.DeleteColumnsWithMissingValuesGreater(GetDeleteColumnsInfo()),
     60        () => Content.DeleteColumnsWithVarianceSmaller(GetDeleteColumnsVariance()),
     61        () => Content.DeleteRowsWithMissingValuesGreater(GetRowsColumnsInfo()),
    6862      };
    6963    }
     
    7266      base.OnContentChanged();
    7367      if (Content != null) {
    74         cmbVariableNames.Items.Clear();
    75         foreach (var name in Content.ManipulationLogic.VariableNames) {
    76           cmbVariableNames.Items.Add(name);
    77         }
    78         cmbVariableNames.SelectedIndex = 0;
    7968        CheckFilters();
    8069      }
     
    8372    protected override void RegisterContentEvents() {
    8473      base.RegisterContentEvents();
    85       Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
     74      Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
    8675    }
    8776
    8877    protected override void DeregisterContentEvents() {
    89       Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
     78      Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
    9079      base.DeregisterContentEvents();
    9180    }
     
    9887
    9988    private void CheckFilters() {
    100       if (Content.FilterLogic.IsFiltered) {
     89      if (Content.PreprocessingData.IsFiltered) {
    10190        tabsPreview.SelectedIndex = 0;
    10291        lstMethods.Enabled = false;
     
    126115    }
    127116
    128     private void ReplaceMissingValues() {
    129       var allIndices = Content.SearchLogic.GetMissingValueIndices();
    130       var columnIndex = cmbVariableNames.SelectedIndex;
    131       var columnIndices = new Dictionary<int, IList<int>>{
    132           {columnIndex,   allIndices[columnIndex]}
    133       };
    134 
    135       switch (cmbReplaceWith.SelectedIndex) {
    136         case 0: //Value
    137           Content.ManipulationLogic.ReplaceIndicesByValue(columnIndices, txtReplaceValue.Text);
    138           break;
    139         case 1: //Average
    140           Content.ManipulationLogic.ReplaceIndicesByAverageValue(columnIndices);
    141           break;
    142         case 2: //Median
    143           Content.ManipulationLogic.ReplaceIndicesByMedianValue(columnIndices);
    144           break;
    145         case 3: //Most Common
    146           Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(columnIndices);
    147           break;
    148         case 4: //Random
    149           Content.ManipulationLogic.ReplaceIndicesByRandomValue(columnIndices);
    150           break;
    151       }
    152     }
    153 
    154117    private void ValidateDeleteColumnsInfo() {
    155118      ValidateDoubleTextBox(txtDeleteColumnsInfo.Text);
    156119      if (btnApply.Enabled) {
    157         var filteredColumns = Content.ManipulationLogic.ColumnsWithMissingValuesGreater(GetDeleteColumnsInfo());
     120        var filteredColumns = Content.ColumnsWithMissingValuesGreater(GetDeleteColumnsInfo());
    158121        int count = filteredColumns.Count;
    159         int columnCount = Content.FilterLogic.PreprocessingData.Columns;
     122        int columnCount = Content.PreprocessingData.Columns;
    160123        lblPreviewColumnsInfo.Text = string.Format("{0} column{1} of {2} ({3}) were detected with more than {4}% missing values.", count, (count > 1 || count == 0 ? "s" : ""), columnCount, string.Format("{0:F2}%", 100d / columnCount * count), txtDeleteColumnsInfo.Text);
    161124
     
    165128          sb.Append(Environment.NewLine);
    166129          sb.Append("Columns: ");
    167           sb.Append(Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
     130          sb.Append(Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
    168131          for (int i = 1; i < filteredColumns.Count; i++) {
    169             string columnName = Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
     132            string columnName = Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(i));
    170133            sb.Append(", ");
    171134            sb.Append(columnName);
     
    186149      ValidateDoubleTextBox(txtDeleteColumnsVariance.Text);
    187150      if (btnApply.Enabled) {
    188         var filteredColumns = Content.ManipulationLogic.ColumnsWithVarianceSmaller(GetDeleteColumnsVariance());
     151        var filteredColumns = Content.ColumnsWithVarianceSmaller(GetDeleteColumnsVariance());
    189152        int count = filteredColumns.Count;
    190         int columnCount = Content.FilterLogic.PreprocessingData.Columns;
     153        int columnCount = Content.PreprocessingData.Columns;
    191154        lblPreviewColumnsVariance.Text = string.Format("{0} column{1} of {2} ({3}) were detected with a variance smaller than {4}.", count, (count > 1 || count == 0 ? "s" : ""), columnCount, string.Format("{0:F2}%", 100d / columnCount * count), txtDeleteColumnsVariance.Text);
    192155
     
    196159          sb.Append(Environment.NewLine);
    197160          sb.Append("Columns: ");
    198           sb.Append(Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
     161          sb.Append(Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
    199162          for (int i = 1; i < filteredColumns.Count; i++) {
    200             string columnName = Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
     163            string columnName = Content.PreprocessingData.VariableNames.ElementAt(filteredColumns.ElementAt(i));
    201164            sb.Append(", ");
    202165            sb.Append(columnName);
     
    217180      ValidateDoubleTextBox(txtDeleteRowsInfo.Text);
    218181      if (btnApply.Enabled) {
    219         int count = Content.ManipulationLogic.RowsWithMissingValuesGreater(GetRowsColumnsInfo()).Count;
    220         int rowCount = Content.FilterLogic.PreprocessingData.Rows;
     182        int count = Content.RowsWithMissingValuesGreater(GetRowsColumnsInfo()).Count;
     183        int rowCount = Content.PreprocessingData.Rows;
    221184        lblPreviewRowsInfo.Text = count + " row" + (count > 1 || count == 0 ? "s" : "") + " of " + rowCount + " (" + string.Format("{0:F2}%", 100d / rowCount * count) + ") were detected with more than " + txtDeleteRowsInfo.Text + "% missing values.";
    222185        if (count > 0) {
     
    228191        lblPreviewRowsInfo.Text = "Preview not possible yet - please input the limit above.";
    229192      }
    230     }
    231 
    232     private void ValidateReplaceWith() {
    233       btnApply.Enabled = false;
    234       string replaceWith = (string)cmbReplaceWith.SelectedItem;
    235       int columnIndex = cmbVariableNames.SelectedIndex;
    236 
    237       if (cmbReplaceWith.SelectedIndex == 0) {
    238         string errorMessage;
    239         string replaceValue = txtReplaceValue.Text;
    240         if (string.IsNullOrEmpty(replaceValue)) {
    241           lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement.";
    242         } else if (!Content.ManipulationLogic.PreProcessingData.Validate(txtReplaceValue.Text, out errorMessage, columnIndex)) {
    243           lblPreviewReplaceMissingValues.Text = "Preview not possible yet - " + errorMessage;
    244         } else {
    245           btnApply.Enabled = true;
    246         }
    247         replaceWith = "\"" + replaceValue + "\"";
    248       } else {
    249         btnApply.Enabled = true;
    250       }
    251       if (btnApply.Enabled) {
    252         var allIndices = Content.SearchLogic.GetMissingValueIndices();
    253         int count = allIndices[columnIndex].Count;
    254         int cellCount = Content.FilterLogic.PreprocessingData.Rows * Content.FilterLogic.PreprocessingData.Columns;
    255         lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "")
    256           + " of " + cellCount + " (" + string.Format("{0:F2}%", 100d / cellCount * count) + ") were detected with missing values which would be replaced with " + replaceWith;
    257         if (count > 0) {
    258           lblPreviewReplaceMissingValues.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to perform the replacement.";
    259         } else {
    260           btnApply.Enabled = false;
    261         }
    262       }
    263     }
    264 
    265     private void ValidateShuffle() {
    266       btnApply.Enabled = true;
    267       lblShuffleProperties.Enabled = false;
    268       lblShuffleProperties.Visible = false;
    269       shuffleSeparatelyCheckbox.Enabled = true;
    270       shuffleSeparatelyCheckbox.Visible = true;
    271193    }
    272194
     
    295217          lblPreviewRowsInfo.Text = "rows successfully deleted.";
    296218          break;
    297         case 3:
    298           lblPreviewReplaceMissingValues.Text = "missing values successfully replaced.";
    299           btnApply.Enabled = false;
    300           break;
    301         case 4:
    302           lblPreviewShuffle.Text = "dataset shuffled successfully.";
    303           btnApply.Enabled = false;
    304           break;
    305219      }
    306220    }
     
    327241      ValidateDeleteRowsInfo();
    328242    }
    329 
    330     private void cmbReplaceWith_SelectedIndexChanged(object sender, EventArgs e) {
    331       bool isReplaceWithValueSelected = cmbReplaceWith.SelectedIndex == 0;
    332       lblValueColon.Visible = isReplaceWithValueSelected;
    333       txtReplaceValue.Visible = isReplaceWithValueSelected;
    334       ValidateReplaceWith();
    335     }
    336 
    337     private void txtReplaceValue_TextChanged(object sender, EventArgs e) {
    338       ValidateReplaceWith();
    339     }
    340243  }
    341244}
Note: See TracChangeset for help on using the changeset viewer.