Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13508 for trunk/sources


Ignore:
Timestamp:
01/14/16 17:51:48 (9 years ago)
Author:
pfleck
Message:

#2559

  • Enabled type selection for creating/importing/exporting/applying.
  • Deleted unnecessary interfaces.
  • Reorganized source files of DataPreprocessing.
Location:
trunk/sources
Files:
3 added
3 deleted
8 edited
27 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r13507 r13508  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
     23using System.IO;
     24using System.Threading.Tasks;
    2525using System.Windows.Forms;
    2626using HeuristicLab.Common;
     
    2828using HeuristicLab.Core.Views;
    2929using HeuristicLab.MainForm;
     30using HeuristicLab.Problems.DataAnalysis;
     31using HeuristicLab.Problems.Instances.DataAnalysis;
     32using HeuristicLab.Problems.Instances.DataAnalysis.Views;
    3033
    3134namespace HeuristicLab.DataPreprocessing.Views {
     
    6871
    6972        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
    70 
    7173        viewShortcutListView.ItemsListView.Items[0].Selected = true;
    7274        viewShortcutListView.Select();
    7375
    74         applyComboBox.Items.Clear();
    75         applyComboBox.DataSource = Content.ExportPossibilities.ToList();
    76         applyComboBox.DisplayMember = "Key";
    77         if (applyComboBox.Items.Count > 0)
    78           applyComboBox.SelectedIndex = 0;
     76        applyTypeContextMenuStrip.Items.Clear();
     77        exportTypeContextMenuStrip.Items.Clear();
     78        foreach (var exportOption in Content.GetSourceExportOptions()) {
     79          var applyMenuItem = new ToolStripMenuItem(exportOption.Key) { Tag = exportOption.Value };
     80          applyMenuItem.Click += applyToolStripMenuItem_Click;
     81          applyTypeContextMenuStrip.Items.Add(applyMenuItem);
     82
     83          var exportMenuItem = new ToolStripMenuItem(exportOption.Key) { Tag = exportOption.Value };
     84          exportMenuItem.Click += exportToolStripMenuItem_Click;
     85          exportTypeContextMenuStrip.Items.Add(exportMenuItem);
     86        }
     87        var exportCsvMenuItem = new ToolStripMenuItem(".csv");
     88        exportCsvMenuItem.Click += exportCsvMenuItem_Click;
     89        exportTypeContextMenuStrip.Items.Add(exportCsvMenuItem);
    7990      } else {
    8091        viewShortcutListView.Content = null;
    8192      }
    8293    }
    83 
    8494    protected override void RegisterContentEvents() {
    8595      base.RegisterContentEvents();
     96      Content.Reset += Content_Reset;
    8697      Content.Data.FilterChanged += Data_FilterChanged;
    8798    }
     
    89100    protected override void DeregisterContentEvents() {
    90101      base.DeregisterContentEvents();
     102      Content.Reset -= Content_Reset;
    91103      Content.Data.FilterChanged -= Data_FilterChanged;
     104    }
     105
     106    void Content_Reset(object sender, EventArgs e) {
     107      OnContentChanged(); // Reset by setting new content
    92108    }
    93109
     
    104120    }
    105121
     122    #region New
     123    private void newButton_Click(object sender, EventArgs e) {
     124      newProblemDataTypeContextMenuStrip.Show(Cursor.Position);
     125    }
     126    private void newRegressionToolStripMenuItem_Click(object sender, EventArgs e) {
     127      Content.Import(new RegressionProblemData());
     128    }
     129    private void newClassificationToolStripMenuItem_Click(object sender, EventArgs e) {
     130      Content.Import(new ClassificationProblemData());
     131    }
     132    private void newTimeSeriesToolStripMenuItem_Click(object sender, EventArgs e) {
     133      Content.Import(new TimeSeriesPrognosisProblemData());
     134    }
     135    #endregion
     136
     137    #region Import
     138    private void importButton_Click(object sender, EventArgs e) {
     139      importProblemDataTypeContextMenuStrip.Show(Cursor.Position);
     140    }
     141    private void importRegressionToolStripMenuItem_Click(object sender, EventArgs e) {
     142      Import(new RegressionCSVInstanceProvider(), new RegressionImportTypeDialog(),
     143        (dialog => ((RegressionImportTypeDialog)dialog).ImportType));
     144    }
     145    private void importClassificationToolStripMenuItem_Click(object sender, EventArgs e) {
     146      Import(new ClassificationCSVInstanceProvider(), new ClassificationImportTypeDialog(),
     147        (dialog => ((ClassificationImportTypeDialog)dialog).ImportType));
     148    }
     149    private void importTimeSeriesToolStripMenuItem_Click(object sender, EventArgs e) {
     150      Import(new TimeSeriesPrognosisCSVInstanceProvider(), new TimeSeriesPrognosisImportTypeDialog(),
     151        (dialog => ((TimeSeriesPrognosisImportTypeDialog)dialog).ImportType));
     152    }
     153    private void Import<TProblemData, TImportType>(DataAnalysisInstanceProvider<TProblemData, TImportType> instanceProvider, DataAnalysisImportTypeDialog importTypeDialog,
     154      Func<DataAnalysisImportTypeDialog, TImportType> getImportType)
     155      where TProblemData : class, IDataAnalysisProblemData
     156      where TImportType : DataAnalysisImportType {
     157      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
     158        Task.Run(() => {
     159          TProblemData instance;
     160          var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     161          // lock active view and show progress bar
     162          var activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     163
     164          try {
     165            var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");
     166
     167            instanceProvider.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; };
     168
     169            instance = instanceProvider.ImportData(importTypeDialog.Path, getImportType(importTypeDialog), importTypeDialog.CSVFormat);
     170          } catch (IOException ex) {
     171            MessageBox.Show(string.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
     172            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     173            return;
     174          }
     175          try {
     176            Content.Import(instance);
     177          } catch (IOException ex) {
     178            MessageBox.Show(string.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(importTypeDialog.Path), Environment.NewLine + ex.Message), "Cannot load instance");
     179          } finally {
     180            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     181          }
     182        });
     183      }
     184    }
     185    #endregion
     186
     187    #region Apply
     188    private void applyInNewTabButton_Click(object sender, EventArgs e) {
     189      applyTypeContextMenuStrip.Show(Cursor.Position);
     190    }
     191    private void applyToolStripMenuItem_Click(object sender, EventArgs e) {
     192      var menuItem = (ToolStripMenuItem)sender;
     193      var itemCreator = (Func<IItem>)menuItem.Tag;
     194      MainFormManager.MainForm.ShowContent(itemCreator());
     195    }
     196    #endregion
     197
     198    #region Export
    106199    private void exportProblemButton_Click(object sender, EventArgs e) {
    107       var exportOption = (KeyValuePair<string, Func<IItem>>)applyComboBox.SelectedItem;
    108       var exportItem = exportOption.Value();
    109 
     200      exportTypeContextMenuStrip.Show(Cursor.Position);
     201    }
     202    private void exportToolStripMenuItem_Click(object sender, EventArgs e) {
     203      var menuItem = (ToolStripMenuItem)sender;
     204      var itemCreator = (Func<IItem>)menuItem.Tag;
    110205      var saveFileDialog = new SaveFileDialog {
    111206        Title = "Save Item",
     
    115210      };
    116211
    117       var content = exportItem as IStorableContent;
    118212      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    119         bool compressed = saveFileDialog.FilterIndex != 1;
    120         ContentManager.Save(content, saveFileDialog.FileName, compressed);
    121       }
    122     }
    123 
    124     private void applyInNewTabButton_Click(object sender, EventArgs e) {
    125       var exportOption = (KeyValuePair<string, Func<IItem>>)applyComboBox.SelectedItem;
    126       var exportItem = exportOption.Value();
    127 
    128       MainFormManager.MainForm.ShowContent(exportItem);
    129     }
    130 
     213        Task.Run(() => {
     214          bool compressed = saveFileDialog.FilterIndex != 1;
     215          var storable = itemCreator() as IStorableContent;
     216          if (storable != null) {
     217            var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     218            var activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     219            try {
     220              mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data.");
     221              ContentManager.Save(storable, saveFileDialog.FileName, compressed);
     222            } finally {
     223              mainForm.RemoveOperationProgressFromContent(activeView.Content);
     224            }
     225          }
     226        });
     227      }
     228    }
     229    private void exportCsvMenuItem_Click(object sender, EventArgs e) {
     230      var saveFileDialog = new SaveFileDialog {
     231        Title = "Save Data",
     232        DefaultExt = "csv",
     233        Filter = "CSV files|*.csv|All files|*.*",
     234        FilterIndex = 1
     235      };
     236
     237      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
     238        Task.Run(() => {
     239          var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     240          var activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     241          try {
     242            var problemData = Content.CreateNewProblemData();
     243            mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data.");
     244            if (problemData is TimeSeriesPrognosisProblemData)
     245              Export(new TimeSeriesPrognosisCSVInstanceProvider(), problemData, saveFileDialog.FileName);
     246            else if (problemData is RegressionProblemData)
     247              Export(new RegressionCSVInstanceProvider(), problemData, saveFileDialog.FileName);
     248            else if (problemData is ClassificationProblemData)
     249              Export(new ClassificationCSVInstanceProvider(), problemData, saveFileDialog.FileName);
     250          } finally {
     251            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     252          }
     253        });
     254      }
     255    }
     256    private void Export<TProblemData, TImportType>(DataAnalysisInstanceProvider<TProblemData, TImportType> instanceProvider,
     257      IDataAnalysisProblemData problemData, string path)
     258      where TProblemData : class, IDataAnalysisProblemData where TImportType : DataAnalysisImportType {
     259      instanceProvider.ExportData((TProblemData)problemData, path);
     260    }
     261    #endregion
     262
     263    #region Undo / Redo
    131264    private void undoButton_Click(object sender, EventArgs e) {
    132265      Content.Data.Undo();
    133266    }
     267    #endregion
    134268  }
    135269}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.designer.cs

    r13507 r13508  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataPreprocessingView));
    4849      this.undoButton = new System.Windows.Forms.Button();
     
    5051      this.exportProblemButton = new System.Windows.Forms.Button();
    5152      this.lblFilterActive = new System.Windows.Forms.Label();
    52       this.applyComboBox = new System.Windows.Forms.ComboBox();
    53       this.exportLabel = new System.Windows.Forms.Label();
    5453      this.redoButton = new System.Windows.Forms.Button();
     54      this.newButton = new System.Windows.Forms.Button();
     55      this.importButton = new System.Windows.Forms.Button();
     56      this.newProblemDataTypeContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     57      this.newRegressionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     58      this.newClassificationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     59      this.newTimeSeriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     60      this.importProblemDataTypeContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     61      this.importRegressionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     62      this.importClassificationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     63      this.importTimeSeriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5564      this.viewShortcutListView = new HeuristicLab.DataPreprocessing.Views.ViewShortcutListView();
     65      this.applyTypeContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     66      this.exportTypeContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    5667      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     68      this.newProblemDataTypeContextMenuStrip.SuspendLayout();
     69      this.importProblemDataTypeContextMenuStrip.SuspendLayout();
    5770      this.SuspendLayout();
    5871      //
     
    7083      //
    7184      this.undoButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Undo;
    72       this.undoButton.Location = new System.Drawing.Point(6, 56);
     85      this.undoButton.Location = new System.Drawing.Point(131, 26);
    7386      this.undoButton.Name = "undoButton";
    7487      this.undoButton.Size = new System.Drawing.Size(24, 24);
     
    8194      //
    8295      this.applyInNewTabButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
    83       this.applyInNewTabButton.Location = new System.Drawing.Point(57, 26);
     96      this.applyInNewTabButton.Location = new System.Drawing.Point(69, 26);
    8497      this.applyInNewTabButton.Name = "applyInNewTabButton";
    8598      this.applyInNewTabButton.Size = new System.Drawing.Size(24, 24);
     
    91104      // exportProblemButton
    92105      //
    93       this.exportProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
    94       this.exportProblemButton.Location = new System.Drawing.Point(87, 26);
     106      this.exportProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.SaveAs;
     107      this.exportProblemButton.Location = new System.Drawing.Point(99, 26);
    95108      this.exportProblemButton.Name = "exportProblemButton";
    96109      this.exportProblemButton.Size = new System.Drawing.Size(24, 24);
    97110      this.exportProblemButton.TabIndex = 3;
    98       this.toolTip.SetToolTip(this.exportProblemButton, "Save");
     111      this.toolTip.SetToolTip(this.exportProblemButton, "Export to File");
    99112      this.exportProblemButton.UseVisualStyleBackColor = true;
    100113      this.exportProblemButton.Click += new System.EventHandler(this.exportProblemButton_Click);
     
    103116      //
    104117      this.lblFilterActive.AutoSize = true;
    105       this.lblFilterActive.Location = new System.Drawing.Point(84, 62);
     118      this.lblFilterActive.Location = new System.Drawing.Point(203, 31);
    106119      this.lblFilterActive.Name = "lblFilterActive";
    107120      this.lblFilterActive.Size = new System.Drawing.Size(277, 13);
     
    110123      this.lblFilterActive.Visible = false;
    111124      //
    112       // applyComboBox
    113       //
    114       this.applyComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    115             | System.Windows.Forms.AnchorStyles.Right)));
    116       this.applyComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    117       this.applyComboBox.FormattingEnabled = true;
    118       this.applyComboBox.Items.AddRange(new object[] {
    119             "Algorithm",
    120             "Problem",
    121             "ProblemData"});
    122       this.applyComboBox.Location = new System.Drawing.Point(117, 28);
    123       this.applyComboBox.Name = "applyComboBox";
    124       this.applyComboBox.Size = new System.Drawing.Size(696, 21);
    125       this.applyComboBox.TabIndex = 4;
    126       //
    127       // exportLabel
    128       //
    129       this.exportLabel.AutoSize = true;
    130       this.exportLabel.Location = new System.Drawing.Point(5, 31);
    131       this.exportLabel.Name = "exportLabel";
    132       this.exportLabel.Size = new System.Drawing.Size(40, 13);
    133       this.exportLabel.TabIndex = 8;
    134       this.exportLabel.Text = "Export:";
    135       //
    136125      // redoButton
    137126      //
    138127      this.redoButton.Enabled = false;
    139128      this.redoButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Redo;
    140       this.redoButton.Location = new System.Drawing.Point(36, 56);
     129      this.redoButton.Location = new System.Drawing.Point(161, 26);
    141130      this.redoButton.Name = "redoButton";
    142131      this.redoButton.Size = new System.Drawing.Size(24, 24);
     
    145134      this.redoButton.UseVisualStyleBackColor = true;
    146135      //
     136      // newButton
     137      //
     138      this.newButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     139      this.newButton.Location = new System.Drawing.Point(6, 26);
     140      this.newButton.Name = "newButton";
     141      this.newButton.Size = new System.Drawing.Size(24, 24);
     142      this.newButton.TabIndex = 3;
     143      this.newButton.UseVisualStyleBackColor = true;
     144      this.newButton.Click += new System.EventHandler(this.newButton_Click);
     145      //
     146      // importButton
     147      //
     148      this.importButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     149      this.importButton.Location = new System.Drawing.Point(36, 26);
     150      this.importButton.Name = "importButton";
     151      this.importButton.Size = new System.Drawing.Size(24, 24);
     152      this.importButton.TabIndex = 3;
     153      this.importButton.UseVisualStyleBackColor = true;
     154      this.importButton.Click += new System.EventHandler(this.importButton_Click);
     155      //
     156      // newProblemDataTypeContextMenuStrip
     157      //
     158      this.newProblemDataTypeContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     159            this.newRegressionToolStripMenuItem,
     160            this.newClassificationToolStripMenuItem,
     161            this.newTimeSeriesToolStripMenuItem});
     162      this.newProblemDataTypeContextMenuStrip.Name = "newProblemDataTypeContextMenuStrip";
     163      this.newProblemDataTypeContextMenuStrip.Size = new System.Drawing.Size(190, 70);
     164      //
     165      // newRegressionToolStripMenuItem
     166      //
     167      this.newRegressionToolStripMenuItem.Name = "newRegressionToolStripMenuItem";
     168      this.newRegressionToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     169      this.newRegressionToolStripMenuItem.Text = "Regression";
     170      this.newRegressionToolStripMenuItem.Click += new System.EventHandler(this.newRegressionToolStripMenuItem_Click);
     171      //
     172      // newClassificationToolStripMenuItem
     173      //
     174      this.newClassificationToolStripMenuItem.Name = "newClassificationToolStripMenuItem";
     175      this.newClassificationToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     176      this.newClassificationToolStripMenuItem.Text = "Classification";
     177      this.newClassificationToolStripMenuItem.Click += new System.EventHandler(this.newClassificationToolStripMenuItem_Click);
     178      //
     179      // newTimeSeriesToolStripMenuItem
     180      //
     181      this.newTimeSeriesToolStripMenuItem.Name = "newTimeSeriesToolStripMenuItem";
     182      this.newTimeSeriesToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     183      this.newTimeSeriesToolStripMenuItem.Text = "Time Series Prognosis";
     184      this.newTimeSeriesToolStripMenuItem.Click += new System.EventHandler(this.newTimeSeriesToolStripMenuItem_Click);
     185      //
     186      // importProblemDataTypeContextMenuStrip
     187      //
     188      this.importProblemDataTypeContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     189            this.importRegressionToolStripMenuItem,
     190            this.importClassificationToolStripMenuItem,
     191            this.importTimeSeriesToolStripMenuItem});
     192      this.importProblemDataTypeContextMenuStrip.Name = "newProblemDataTypeContextMenuStrip";
     193      this.importProblemDataTypeContextMenuStrip.Size = new System.Drawing.Size(190, 92);
     194      //
     195      // importRegressionToolStripMenuItem
     196      //
     197      this.importRegressionToolStripMenuItem.Name = "importRegressionToolStripMenuItem";
     198      this.importRegressionToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     199      this.importRegressionToolStripMenuItem.Text = "Regression";
     200      this.importRegressionToolStripMenuItem.Click += new System.EventHandler(this.importRegressionToolStripMenuItem_Click);
     201      //
     202      // importClassificationToolStripMenuItem
     203      //
     204      this.importClassificationToolStripMenuItem.Name = "importClassificationToolStripMenuItem";
     205      this.importClassificationToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     206      this.importClassificationToolStripMenuItem.Text = "Classification";
     207      this.importClassificationToolStripMenuItem.Click += new System.EventHandler(this.importClassificationToolStripMenuItem_Click);
     208      //
     209      // importTimeSeriesToolStripMenuItem
     210      //
     211      this.importTimeSeriesToolStripMenuItem.Name = "importTimeSeriesToolStripMenuItem";
     212      this.importTimeSeriesToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
     213      this.importTimeSeriesToolStripMenuItem.Text = "Time Series Prognosis";
     214      this.importTimeSeriesToolStripMenuItem.Click += new System.EventHandler(this.importTimeSeriesToolStripMenuItem_Click);
     215      //
    147216      // viewShortcutListView
    148217      //
     
    152221      this.viewShortcutListView.Caption = "ViewShortcutCollection View";
    153222      this.viewShortcutListView.Content = null;
    154       this.viewShortcutListView.Location = new System.Drawing.Point(4, 86);
     223      this.viewShortcutListView.Location = new System.Drawing.Point(4, 56);
    155224      this.viewShortcutListView.Name = "viewShortcutListView";
    156225      this.viewShortcutListView.ReadOnly = false;
    157       this.viewShortcutListView.Size = new System.Drawing.Size(831, 360);
     226      this.viewShortcutListView.Size = new System.Drawing.Size(831, 390);
    158227      this.viewShortcutListView.TabIndex = 7;
     228      //
     229      // applyTypeContextMenuStrip
     230      //
     231      this.applyTypeContextMenuStrip.Name = "newProblemDataTypeContextMenuStrip";
     232      this.applyTypeContextMenuStrip.Size = new System.Drawing.Size(61, 4);
     233      //
     234      // exportTypeContextMenuStrip
     235      //
     236      this.exportTypeContextMenuStrip.Name = "newProblemDataTypeContextMenuStrip";
     237      this.exportTypeContextMenuStrip.Size = new System.Drawing.Size(61, 4);
    159238      //
    160239      // DataPreprocessingView
     
    162241      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    163242      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    164       this.Controls.Add(this.applyComboBox);
    165       this.Controls.Add(this.exportLabel);
     243      this.Controls.Add(this.newButton);
     244      this.Controls.Add(this.importButton);
     245      this.Controls.Add(this.applyInNewTabButton);
    166246      this.Controls.Add(this.exportProblemButton);
    167       this.Controls.Add(this.applyInNewTabButton);
     247      this.Controls.Add(this.undoButton);
     248      this.Controls.Add(this.redoButton);
    168249      this.Controls.Add(this.lblFilterActive);
    169250      this.Controls.Add(this.viewShortcutListView);
    170       this.Controls.Add(this.redoButton);
    171       this.Controls.Add(this.undoButton);
    172251      this.Name = "DataPreprocessingView";
    173252      this.Size = new System.Drawing.Size(838, 449);
    174       this.Controls.SetChildIndex(this.undoButton, 0);
    175       this.Controls.SetChildIndex(this.redoButton, 0);
    176253      this.Controls.SetChildIndex(this.viewShortcutListView, 0);
    177254      this.Controls.SetChildIndex(this.lblFilterActive, 0);
     255      this.Controls.SetChildIndex(this.redoButton, 0);
     256      this.Controls.SetChildIndex(this.undoButton, 0);
     257      this.Controls.SetChildIndex(this.exportProblemButton, 0);
     258      this.Controls.SetChildIndex(this.applyInNewTabButton, 0);
     259      this.Controls.SetChildIndex(this.importButton, 0);
     260      this.Controls.SetChildIndex(this.newButton, 0);
     261      this.Controls.SetChildIndex(this.infoLabel, 0);
     262      this.Controls.SetChildIndex(this.nameTextBox, 0);
    178263      this.Controls.SetChildIndex(this.nameLabel, 0);
    179       this.Controls.SetChildIndex(this.nameTextBox, 0);
    180       this.Controls.SetChildIndex(this.infoLabel, 0);
    181       this.Controls.SetChildIndex(this.applyInNewTabButton, 0);
    182       this.Controls.SetChildIndex(this.exportProblemButton, 0);
    183       this.Controls.SetChildIndex(this.exportLabel, 0);
    184       this.Controls.SetChildIndex(this.applyComboBox, 0);
    185264      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     265      this.newProblemDataTypeContextMenuStrip.ResumeLayout(false);
     266      this.importProblemDataTypeContextMenuStrip.ResumeLayout(false);
    186267      this.ResumeLayout(false);
    187268      this.PerformLayout();
     
    196277    private ViewShortcutListView viewShortcutListView;
    197278    private System.Windows.Forms.Label lblFilterActive;
    198     private System.Windows.Forms.Label exportLabel;
    199279    private System.Windows.Forms.Button redoButton;
    200     private System.Windows.Forms.ComboBox applyComboBox;
     280    private System.Windows.Forms.Button newButton;
     281    private System.Windows.Forms.Button importButton;
     282    private System.Windows.Forms.ContextMenuStrip newProblemDataTypeContextMenuStrip;
     283    private System.Windows.Forms.ToolStripMenuItem newRegressionToolStripMenuItem;
     284    private System.Windows.Forms.ToolStripMenuItem newClassificationToolStripMenuItem;
     285    private System.Windows.Forms.ToolStripMenuItem newTimeSeriesToolStripMenuItem;
     286    private System.Windows.Forms.ContextMenuStrip importProblemDataTypeContextMenuStrip;
     287    private System.Windows.Forms.ToolStripMenuItem importRegressionToolStripMenuItem;
     288    private System.Windows.Forms.ToolStripMenuItem importClassificationToolStripMenuItem;
     289    private System.Windows.Forms.ToolStripMenuItem importTimeSeriesToolStripMenuItem;
     290    private System.Windows.Forms.ContextMenuStrip applyTypeContextMenuStrip;
     291    private System.Windows.Forms.ContextMenuStrip exportTypeContextMenuStrip;
    201292  }
    202293}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessorStarter.cs

    r13502 r13508  
    3434      IDataAnalysisProblem problem;
    3535      GetMostOuterContent(currentView as Control, out algorithm, out problem);
    36       var context = new PreprocessingContext(algorithm ?? problem ?? problemData as IItem);
     36      var context = new PreprocessingContext(problemData, algorithm ?? problem ?? problemData as IItem);
    3737      MainFormManager.MainForm.ShowContent(context);
    3838    }
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r13502 r13508  
    255255      <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project>
    256256      <Name>HeuristicLab.Collections-3.3</Name>
     257      <Private>False</Private>
    257258    </ProjectReference>
    258259    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
     
    309310      <Project>{C664305E-497C-4533-A140-967DEDB05C19}</Project>
    310311      <Name>HeuristicLab.Optimizer-3.3</Name>
     312      <Private>False</Private>
    311313    </ProjectReference>
    312314    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
     
    323325      <Project>{df87c13e-a889-46ff-8153-66dcaa8c5674}</Project>
    324326      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
     327      <Private>False</Private>
     328    </ProjectReference>
     329    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances.DataAnalysis.Views\3.3\HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.csproj">
     330      <Project>{72232235-B6CF-4E6C-B086-9E9E11AA0717}</Project>
     331      <Name>HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3</Name>
     332      <Private>False</Private>
     333    </ProjectReference>
     334    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances.DataAnalysis\3.3\HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj">
     335      <Project>{94C7714E-29D4-4D6D-B213-2C18D627AB75}</Project>
     336      <Name>HeuristicLab.Problems.Instances.DataAnalysis-3.3</Name>
     337      <Private>False</Private>
     338    </ProjectReference>
     339    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
     340      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
     341      <Name>HeuristicLab.Problems.Instances-3.3</Name>
    325342      <Private>False</Private>
    326343    </ProjectReference>
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/Plugin.cs.frame

    r13504 r13508  
    4444  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    4545  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Views", "3.4")]
     46  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     47  [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
     48  [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis.Views", "3.3")]
    4649  [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")]
    4750  public class HeuristicLabDataPreprocessingViewPlugin : PluginBase {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/CorrelationMatrixContent.cs

    r13507 r13508  
    2121
    2222using System.Drawing;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4039    public DataAnalysisProblemData ProblemData {
    4140      get {
    42         // ToDo: avoid iterating
    43         return Context.ExportPossibilities.Select(p => p.Value()).OfType<DataAnalysisProblemData>().Single();
     41        return (DataAnalysisProblemData)Context.CreateNewProblemData();
    4442        //var creator = new ProblemDataCreator(Context);
    4543        //return (DataAnalysisProblemData)creator.CreateProblemData();
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs

    r13507 r13508  
    1111    }
    1212
    13     public IDataGridLogic DataGridLogic { get; private set; }
    14     public ISearchLogic SearchLogic { get; private set; }
     13    //public DataGridLogic DataGridLogic { get; private set; }
     14    public SearchLogic SearchLogic { get; private set; }
    1515
    1616    public DataCompletenessChartContent(SearchLogic searchLogic) {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs

    r13507 r13508  
    3838    }
    3939
    40     public IManipulationLogic ManipulationLogic { get; private set; }
    41     public IFilterLogic FilterLogic { get; private set; }
     40    public ManipulationLogic ManipulationLogic { get; private set; }
     41    public FilterLogic FilterLogic { get; private set; }
    4242
    4343    public int Rows {
     
    9797
    9898
    99     public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {
     99    public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) {
    100100      ManipulationLogic = theManipulationLogic;
    101101      FilterLogic = theFilterLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/FilterContent.cs

    r13507 r13508  
    3535    private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>();
    3636
    37     public IFilterLogic FilterLogic { get; private set; }
     37    public FilterLogic FilterLogic { get; private set; }
    3838
    3939    public ICheckedItemCollection<IFilter> Filters {
     
    5656    }
    5757
    58     public FilterContent(IFilterLogic filterLogic) {
     58    public FilterContent(FilterLogic filterLogic) {
    5959      FilterLogic = filterLogic;
    6060    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/IDataGridContent.cs

    r13507 r13508  
    2626  public interface IDataGridContent : IStringConvertibleMatrix {
    2727    ITransactionalPreprocessingData PreProcessingData { get; }
    28     IManipulationLogic ManipulationLogic { get; }
    29     IFilterLogic FilterLogic { get; }
     28    ManipulationLogic ManipulationLogic { get; }
     29    FilterLogic FilterLogic { get; }
    3030
    3131    IDictionary<int, IList<int>> Selection { get; set; }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs

    r13507 r13508  
    2929  public class ManipulationContent : Item, IViewShortcut {
    3030
    31     private IManipulationLogic manipulationLogic;
    32     private ISearchLogic searchLogic;
    33     private IFilterLogic filterLogic;
     31    private ManipulationLogic manipulationLogic;
     32    private SearchLogic searchLogic;
     33    private FilterLogic filterLogic;
    3434
    35     public IManipulationLogic ManipulationLogic { get { return manipulationLogic; } }
    36     public ISearchLogic SearchLogic { get { return searchLogic; } }
    37     public IFilterLogic FilterLogic { get { return filterLogic; } }
     35    public ManipulationLogic ManipulationLogic { get { return manipulationLogic; } }
     36    public SearchLogic SearchLogic { get { return searchLogic; } }
     37    public FilterLogic FilterLogic { get { return filterLogic; } }
    3838
    3939    public static new Image StaticItemImage {
     
    4141    }
    4242
    43     public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFilterLogic) {
     43    public ManipulationContent(ManipulationLogic theManipulationLogic, SearchLogic theSearchLogic, FilterLogic theFilterLogic) {
    4444      manipulationLogic = theManipulationLogic;
    4545      searchLogic = theSearchLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/StatisticsContent.cs

    r13507 r13508  
    2828  public class StatisticsContent : Item, IViewShortcut {
    2929
    30     private readonly IStatisticsLogic statisticsLogic;
    31     public StatisticsContent(IStatisticsLogic theStatisticsLogic) {
     30    private readonly StatisticsLogic statisticsLogic;
     31    public StatisticsContent(StatisticsLogic theStatisticsLogic) {
    3232      statisticsLogic = theStatisticsLogic;
    3333    }
     
    3838    }
    3939
    40     public IStatisticsLogic StatisticsLogic {
     40    public StatisticsLogic StatisticsLogic {
    4141      get { return statisticsLogic; }
    4242    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/TransformationContent.cs

    r13507 r13508  
    3030
    3131    public IPreprocessingData Data { get; private set; }
    32     public IFilterLogic FilterLogic { get; private set; }
     32    public FilterLogic FilterLogic { get; private set; }
    3333
    3434    public ICheckedItemList<ITransformation> CheckedTransformationList { get; private set; }
     
    3838    }
    3939
    40     public TransformationContent(IPreprocessingData data, IFilterLogic filterLogic) {
     40    public TransformationContent(IPreprocessingData data, FilterLogic filterLogic) {
    4141      Data = data;
    4242      CheckedTransformationList = new CheckedItemList<ITransformation>();
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r13502 r13508  
    7878  </ItemGroup>
    7979  <ItemGroup>
    80     <Compile Include="Implementations\ScatterPlotContent.cs" />
    81     <Compile Include="Implementations\DataCompletenessChartContent.cs" />
    82     <Compile Include="Implementations\FilteredPreprocessingData.cs" />
    83     <Compile Include="Implementations\ManipulationContent.cs" />
    84     <Compile Include="Implementations\PreprocessingChartContent.cs" />
    85     <Compile Include="Implementations\PreprocessingData.cs" />
    86     <Compile Include="Implementations\PreprocessingDataTable.cs" />
    87     <Compile Include="Interfaces\IViewChartShortcut.cs" />
    88     <Compile Include="Interfaces\IFilteredPreprocessingData.cs" />
    89     <Compile Include="Implementations\CorrelationMatrixContent.cs" />
     80    <Compile Include="Content\ScatterPlotContent.cs" />
     81    <Compile Include="Content\DataCompletenessChartContent.cs" />
     82    <Compile Include="Data\FilteredPreprocessingData.cs" />
     83    <Compile Include="Content\ManipulationContent.cs" />
     84    <Compile Include="Content\PreprocessingChartContent.cs" />
     85    <Compile Include="Data\PreprocessingData.cs" />
     86    <Compile Include="Content\PreprocessingDataTable.cs" />
     87    <Compile Include="Content\IViewChartShortcut.cs" />
     88    <Compile Include="Data\IFilteredPreprocessingData.cs" />
     89    <Compile Include="Content\CorrelationMatrixContent.cs" />
    9090    <Compile Include="PreprocessingTransformator.cs" />
    91     <Compile Include="Utils\DataPreprocessingChangedEvent.cs" />
    92     <Compile Include="Implementations\Filter\ComparisonFilter.cs" />
    93     <Compile Include="Implementations\Filter\IFilter.cs" />
    94     <Compile Include="Implementations\ManipulationLogic.cs" />
    95     <Compile Include="Interfaces\IPreprocessingData.cs" />
    96     <Compile Include="Interfaces\IDataGridLogic.cs" />
    97     <Compile Include="Implementations\FilterContent.cs" />
    98     <Compile Include="Implementations\FilterLogic.cs" />
    99     <Compile Include="Implementations\HistogramContent.cs" />
    100     <Compile Include="Implementations\LineChartContent.cs" />
    101     <Compile Include="Implementations\StatisticsContent.cs" />
    102     <Compile Include="Implementations\TransformationContent.cs" />
    103     <Compile Include="Interfaces\IFilterLogic.cs" />
    104     <Compile Include="Interfaces\IManipulationLogic.cs" />
    105     <Compile Include="Interfaces\ITransformationLogic.cs" />
    106     <Compile Include="Interfaces\IViewShortcut.cs" />
     91    <Compile Include="Data\DataPreprocessingChangedEvent.cs" />
     92    <Compile Include="Logic\Filter\ComparisonFilter.cs" />
     93    <Compile Include="Logic\Filter\IFilter.cs" />
     94    <Compile Include="Logic\ManipulationLogic.cs" />
     95    <Compile Include="Data\IPreprocessingData.cs" />
     96    <Compile Include="Content\FilterContent.cs" />
     97    <Compile Include="Logic\FilterLogic.cs" />
     98    <Compile Include="Content\HistogramContent.cs" />
     99    <Compile Include="Content\LineChartContent.cs" />
     100    <Compile Include="Content\StatisticsContent.cs" />
     101    <Compile Include="Content\TransformationContent.cs" />
     102    <Compile Include="Content\IViewShortcut.cs" />
    107103    <Compile Include="ProblemDataCreator.cs" />
    108104    <None Include="Plugin.cs.frame" />
    109     <Compile Include="Implementations\DataGridContent.cs" />
     105    <Compile Include="Content\DataGridContent.cs" />
    110106    <Compile Include="PreprocessingContext.cs" />
    111     <Compile Include="Implementations\TransactionalPreprocessingData.cs" />
    112     <Compile Include="Implementations\SearchLogic.cs" />
    113     <Compile Include="Implementations\StatisticsLogic.cs" />
    114     <Compile Include="Interfaces\IDataGridContent.cs" />
    115     <Compile Include="Interfaces\ISearchLogic.cs" />
    116     <Compile Include="Interfaces\IStatisticsLogic.cs" />
    117     <Compile Include="Interfaces\ITransactionalPreprocessingData.cs" />
     107    <Compile Include="Data\TransactionalPreprocessingData.cs" />
     108    <Compile Include="Logic\SearchLogic.cs" />
     109    <Compile Include="Logic\StatisticsLogic.cs" />
     110    <Compile Include="Content\IDataGridContent.cs" />
     111    <Compile Include="Data\ITransactionalPreprocessingData.cs" />
    118112    <Compile Include="Plugin.cs" />
    119113    <Compile Include="Properties\AssemblyInfo.cs" />
     
    162156      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    163157      <Name>HeuristicLab.Persistence-3.3</Name>
     158      <Private>False</Private>
    164159    </ProjectReference>
    165160    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class FilterLogic : IFilterLogic {
     28  public class FilterLogic {
    2929
    3030    public IFilteredPreprocessingData PreprocessingData { get; private set; }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class ManipulationLogic : IManipulationLogic {
     28  public class ManipulationLogic {
    2929    private readonly ITransactionalPreprocessingData preprocessingData;
    30     private readonly IStatisticsLogic statisticsLogic;
    31     private readonly ISearchLogic searchLogic;
     30    private readonly StatisticsLogic statisticsLogic;
     31    private readonly SearchLogic searchLogic;
    3232
    3333    public IEnumerable<string> VariableNames {
     
    3939    }
    4040
    41     public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic) {
     41    public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, SearchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {
    4242      preprocessingData = _prepocessingData;
    4343      searchLogic = theSearchLogic;
     
    5151    }
    5252
    53     public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     53    public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    5454      preprocessingData.InTransaction(() => {
    5555        foreach (var column in cells) {
     
    6565    }
    6666
    67     public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     67    public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    6868      preprocessingData.InTransaction(() => {
    6969        foreach (var column in cells) {
     
    7979    }
    8080
    81     public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     81    public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    8282      preprocessingData.InTransaction(() => {
    8383        Random r = new Random();
     
    209209    }
    210210
    211     public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     211    public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    212212      preprocessingData.InTransaction(() => {
    213213        foreach (var column in cells) {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/SearchLogic.cs

    r13507 r13508  
    2525
    2626namespace HeuristicLab.DataPreprocessing {
    27   public class SearchLogic : ISearchLogic {
     27  public class SearchLogic {
    2828    private readonly ITransactionalPreprocessingData preprocessingData;
    29     private readonly IFilterLogic filterLogic;
     29    private readonly FilterLogic filterLogic;
    3030
    3131    private Dictionary<int, IList<int>> MissingValueIndicies { get; set; }
     
    4444    }
    4545
    46     public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, IFilterLogic theFilterLogic) {
     46    public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, FilterLogic theFilterLogic) {
    4747      preprocessingData = thePreprocessingData;
    4848      filterLogic = theFilterLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class StatisticsLogic : IStatisticsLogic {
     28  public class StatisticsLogic {
    2929
    3030    private readonly ITransactionalPreprocessingData preprocessingData;
    31     private readonly ISearchLogic searchLogic;
    32 
    33     public StatisticsLogic(ITransactionalPreprocessingData thePreprocessingData, ISearchLogic theSearchLogic) {
     31    private readonly SearchLogic searchLogic;
     32
     33    public StatisticsLogic(ITransactionalPreprocessingData thePreprocessingData, SearchLogic theSearchLogic) {
    3434      preprocessingData = thePreprocessingData;
    3535      searchLogic = theSearchLogic;
     
    7171    }
    7272
    73     public T GetMin<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     73    public T GetMin<T>(int columnIndex, bool considerSelection = false) where T : IComparable<T> {
    7474      var min = default(T);
    7575      if (preprocessingData.VariableHasType<T>(columnIndex)) {
     
    8282    }
    8383
    84     public T GetMax<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     84    public T GetMax<T>(int columnIndex, bool considerSelection = false) where T : IComparable<T> {
    8585      var max = default(T);
    8686      if (preprocessingData.VariableHasType<T>(columnIndex)) {
     
    9393    }
    9494
    95     public double GetMedian(int columnIndex, bool considerSelection) {
     95    public double GetMedian(int columnIndex, bool considerSelection = false) {
    9696      double median = double.NaN;
    9797      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    104104    }
    105105
    106     public double GetAverage(int columnIndex, bool considerSelection) {
     106    public double GetAverage(int columnIndex, bool considerSelection = false) {
    107107      double avg = double.NaN;
    108108      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    115115    }
    116116
    117     public DateTime GetMedianDateTime(int columnIndex, bool considerSelection) {
     117    public DateTime GetMedianDateTime(int columnIndex, bool considerSelection = false) {
    118118      DateTime median = new DateTime();
    119119      if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
     
    123123    }
    124124
    125     public DateTime GetAverageDateTime(int columnIndex, bool considerSelection) {
     125    public DateTime GetAverageDateTime(int columnIndex, bool considerSelection = false) {
    126126      DateTime avg = new DateTime();
    127127      if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
     
    131131    }
    132132
    133     public T GetMostCommonValue<T>(int columnIndex, bool considerSelection) {
     133    public T GetMostCommonValue<T>(int columnIndex, bool considerSelection = false) {
    134134      var values = GetValuesWithoutNaN<T>(columnIndex, considerSelection);
    135135      if (!values.Any())
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/PreprocessingContext.cs

    r13507 r13508  
    3535    public string Filename { get; set; }
    3636
    37     public IEnumerable<KeyValuePair<string, Func<IItem>>> ExportPossibilities {
    38       get {
    39         var algorithm = Source as IAlgorithm;
    40         if (algorithm != null)
    41           yield return new KeyValuePair<string, Func<IItem>>(algorithm.GetType().GetPrettyName(), () => ExportAlgorithm(algorithm));
    42 
    43         var problem = algorithm != null ? algorithm.Problem as IDataAnalysisProblem : Source as IDataAnalysisProblem;
    44         if (problem != null)
    45           yield return new KeyValuePair<string, Func<IItem>>(problem.GetType().GetPrettyName(), () => ExportProblem(problem));
    46 
    47         var problemData = problem != null ? problem.ProblemData : Source as IDataAnalysisProblemData;
    48         if (problemData != null)
    49           yield return new KeyValuePair<string, Func<IItem>>(problemData.GetType().GetPrettyName(), () => ExportProblemData(problemData));
    50 
    51         // ToDo: Export CSV
    52       }
    53     }
    54     public bool CanExport {
    55       get { return Source is IAlgorithm || Source is IDataAnalysisProblem || Source is IDataAnalysisProblemData; }
    56     }
    57 
    5837    [Storable]
    5938    public IFilteredPreprocessingData Data { get; private set; }
     
    6241    private IItem Source { get; set; }
    6342
     43    public event EventHandler Reset;
    6444
    65     public PreprocessingContext() : this(new RegressionProblemData()) {
    66       Name = "Data Preprocessing";
     45    #region Constructors
     46    public PreprocessingContext()
     47      : this(new RegressionProblemData()) {
    6748    }
    68     public PreprocessingContext(IItem source)
     49    public PreprocessingContext(IDataAnalysisProblemData problemData, IItem source = null)
    6950      : base("Data Preprocessing") {
    70       Import(source);
     51      if (problemData == null) throw new ArgumentNullException("problemData");
     52      Import(problemData, source);
    7153    }
    7254
     
    7961      Data = cloner.Clone(original.Data);
    8062    }
    81 
    8263    public override IDeepCloneable Clone(Cloner cloner) {
    8364      return new PreprocessingContext(this, cloner);
    8465    }
     66    #endregion
    8567
    8668    #region Import
    87     public void Import(IItem source) {
    88       Source = source;
    89       var namedSource = source as INamedItem;
    90       if (namedSource != null) Name = "Preprocessing: " + namedSource.Name;
    91 
    92       var dataSource = ExtractProblemData(source);
    93       Data = new FilteredPreprocessingData(new TransactionalPreprocessingData(dataSource));
     69    public void Import(IDataAnalysisProblemData problemData, IItem source = null) {
     70      if (problemData == null) throw new ArgumentNullException("problemData");
     71      if (source != null && ExtractProblemData(source) != problemData)
     72        throw new ArgumentException("The ProblemData extracted from the Source is different than the given ProblemData.");
     73      Source = source ?? problemData;
     74      var namedSource = Source as INamedItem;
     75      if (namedSource != null)
     76        Name = "Preprocessing " + namedSource.Name;
     77      Data = new FilteredPreprocessingData(new TransactionalPreprocessingData(problemData));
     78      OnReset();
     79      // Reset GUI:
     80      // - OnContentChanged for PreprocessingView!
     81      // event? task(async import)?
    9482    }
    95 
    9683    private IDataAnalysisProblemData ExtractProblemData(IItem source) {
    9784      var algorithm = source as Algorithm;
     
    10390
    10491    #region Export
    105     public IItem Export() {
    106       if (Source is IAlgorithm)
    107         return ExportAlgorithm((IAlgorithm)Source);
    108       if (Source is IDataAnalysisProblem)
    109         return ExportProblem((IDataAnalysisProblem)Source);
    110       if (Source is IDataAnalysisProblemData)
    111         return ExportProblemData((IDataAnalysisProblemData)Source);
    112       return null;
     92    public bool CanExport {
     93      get { return Source is IAlgorithm || Source is IDataAnalysisProblem || Source is IDataAnalysisProblemData; }
    11394    }
     95    public IEnumerable<KeyValuePair<string, Func<IItem>>> GetSourceExportOptions() {
     96      var algorithm = Source as IAlgorithm;
     97      if (algorithm != null)
     98        yield return new KeyValuePair<string, Func<IItem>>(
     99          algorithm.GetType().GetPrettyName(),
     100          () => ExportAlgorithm(algorithm));
     101
     102      var problem = algorithm != null ? algorithm.Problem as IDataAnalysisProblem : Source as IDataAnalysisProblem;
     103      if (problem != null)
     104        yield return new KeyValuePair<string, Func<IItem>>(
     105          problem.GetType().GetPrettyName(),
     106          () => ExportProblem(problem));
     107
     108      var problemData = problem != null ? problem.ProblemData : Source as IDataAnalysisProblemData;
     109      if (problemData != null)
     110        yield return new KeyValuePair<string, Func<IItem>>(
     111          problemData.GetType().GetPrettyName(),
     112          () => ExportProblemData(problemData));
     113    }
     114
    114115    private IAlgorithm ExportAlgorithm(IAlgorithm source) {
    115116      var preprocessedAlgorithm = (IAlgorithm)source.Clone();
     
    117118      preprocessedAlgorithm.Runs.Clear();
    118119      var problem = (IDataAnalysisProblem)preprocessedAlgorithm.Problem;
    119       SetNewProblemData(problem);
     120      problem.ProblemDataParameter.ActualValue = CreateNewProblemData();
    120121      return preprocessedAlgorithm;
    121122    }
    122123    private IDataAnalysisProblem ExportProblem(IDataAnalysisProblem source) {
    123124      var preprocessedProblem = (IDataAnalysisProblem)source.Clone();
    124       SetNewProblemData(preprocessedProblem);
     125      preprocessedProblem.ProblemDataParameter.ActualValue = CreateNewProblemData();
    125126      return preprocessedProblem;
    126127    }
    127128    private IDataAnalysisProblemData ExportProblemData(IDataAnalysisProblemData source) {
     129      return CreateNewProblemData();
     130    }
     131
     132    public IDataAnalysisProblemData CreateNewProblemData() {
    128133      var creator = new ProblemDataCreator(this);
    129       var preprocessedProblemData = creator.CreateProblemData(source);
    130       preprocessedProblemData.Name = "Preprocessed " + source.Name;
    131       return preprocessedProblemData;
    132     }
    133     private void SetNewProblemData(IDataAnalysisProblem problem) {
    134       var data = ExtractProblemData(problem.ProblemData);
    135       problem.ProblemDataParameter.ActualValue = data;
    136       problem.Name = "Preprocessed " + problem.Name;
     134      var oldProblemData = ExtractProblemData(Source);
     135      var newProblemData = creator.CreateProblemData(oldProblemData);
     136      newProblemData.Name = "Preprocessed " + oldProblemData.Name;
     137      return newProblemData;
    137138    }
    138139    #endregion
     140
     141    protected virtual void OnReset() {
     142      if (Reset != null)
     143        Reset(this, EventArgs.Empty);
     144    }
    139145  }
    140146}
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r13502 r13508  
    4848      IDataAnalysisProblemData problemData;
    4949
    50       if (oldProblemData is RegressionProblemData) {
     50      if (oldProblemData is TimeSeriesPrognosisProblemData) {
     51        problemData = CreateTimeSeriesPrognosisData((TimeSeriesPrognosisProblemData)oldProblemData);
     52      } else if (oldProblemData is RegressionProblemData) {
    5153        problemData = CreateRegressionData((RegressionProblemData)oldProblemData);
    5254      } else if (oldProblemData is ClassificationProblemData) {
     
    6971    }
    7072
     73    private IDataAnalysisProblemData CreateTimeSeriesPrognosisData(TimeSeriesPrognosisProblemData oldProblemData) {
     74      var targetVariable = oldProblemData.TargetVariable;
     75      if (!context.Data.VariableNames.Contains(targetVariable))
     76        targetVariable = context.Data.VariableNames.First();
     77      var inputVariables = GetDoubleInputVariables(targetVariable);
     78      var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     79        TrainingHorizon = oldProblemData.TrainingHorizon,
     80        TestHorizon = oldProblemData.TestHorizon
     81      };
     82      return newProblemData;
     83    }
     84
    7185    private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) {
    7286      var targetVariable = oldProblemData.TargetVariable;
     
    8397        targetVariable = context.Data.VariableNames.First();
    8498      var inputVariables = GetDoubleInputVariables(targetVariable);
    85       var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);
    86       newProblemData.PositiveClass = oldProblemData.PositiveClass;
     99      var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     100        PositiveClass = oldProblemData.PositiveClass
     101      };
    87102      return newProblemData;
    88103    }
Note: See TracChangeset for help on using the changeset viewer.