Changeset 13508 for trunk/sources
- Timestamp:
- 01/14/16 17:51:48 (9 years ago)
- 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 21 21 22 22 using System; 23 using System. Collections.Generic;24 using System. Linq;23 using System.IO; 24 using System.Threading.Tasks; 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Common; … … 28 28 using HeuristicLab.Core.Views; 29 29 using HeuristicLab.MainForm; 30 using HeuristicLab.Problems.DataAnalysis; 31 using HeuristicLab.Problems.Instances.DataAnalysis; 32 using HeuristicLab.Problems.Instances.DataAnalysis.Views; 30 33 31 34 namespace HeuristicLab.DataPreprocessing.Views { … … 68 71 69 72 viewShortcutListView.Content = viewShortcuts.AsReadOnly(); 70 71 73 viewShortcutListView.ItemsListView.Items[0].Selected = true; 72 74 viewShortcutListView.Select(); 73 75 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); 79 90 } else { 80 91 viewShortcutListView.Content = null; 81 92 } 82 93 } 83 84 94 protected override void RegisterContentEvents() { 85 95 base.RegisterContentEvents(); 96 Content.Reset += Content_Reset; 86 97 Content.Data.FilterChanged += Data_FilterChanged; 87 98 } … … 89 100 protected override void DeregisterContentEvents() { 90 101 base.DeregisterContentEvents(); 102 Content.Reset -= Content_Reset; 91 103 Content.Data.FilterChanged -= Data_FilterChanged; 104 } 105 106 void Content_Reset(object sender, EventArgs e) { 107 OnContentChanged(); // Reset by setting new content 92 108 } 93 109 … … 104 120 } 105 121 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 106 199 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; 110 205 var saveFileDialog = new SaveFileDialog { 111 206 Title = "Save Item", … … 115 210 }; 116 211 117 var content = exportItem as IStorableContent;118 212 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 131 264 private void undoButton_Click(object sender, EventArgs e) { 132 265 Content.Data.Undo(); 133 266 } 267 #endregion 134 268 } 135 269 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.designer.cs
r13507 r13508 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataPreprocessingView)); 48 49 this.undoButton = new System.Windows.Forms.Button(); … … 50 51 this.exportProblemButton = new System.Windows.Forms.Button(); 51 52 this.lblFilterActive = new System.Windows.Forms.Label(); 52 this.applyComboBox = new System.Windows.Forms.ComboBox();53 this.exportLabel = new System.Windows.Forms.Label();54 53 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(); 55 64 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); 56 67 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 68 this.newProblemDataTypeContextMenuStrip.SuspendLayout(); 69 this.importProblemDataTypeContextMenuStrip.SuspendLayout(); 57 70 this.SuspendLayout(); 58 71 // … … 70 83 // 71 84 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); 73 86 this.undoButton.Name = "undoButton"; 74 87 this.undoButton.Size = new System.Drawing.Size(24, 24); … … 81 94 // 82 95 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); 84 97 this.applyInNewTabButton.Name = "applyInNewTabButton"; 85 98 this.applyInNewTabButton.Size = new System.Drawing.Size(24, 24); … … 91 104 // exportProblemButton 92 105 // 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); 95 108 this.exportProblemButton.Name = "exportProblemButton"; 96 109 this.exportProblemButton.Size = new System.Drawing.Size(24, 24); 97 110 this.exportProblemButton.TabIndex = 3; 98 this.toolTip.SetToolTip(this.exportProblemButton, " Save");111 this.toolTip.SetToolTip(this.exportProblemButton, "Export to File"); 99 112 this.exportProblemButton.UseVisualStyleBackColor = true; 100 113 this.exportProblemButton.Click += new System.EventHandler(this.exportProblemButton_Click); … … 103 116 // 104 117 this.lblFilterActive.AutoSize = true; 105 this.lblFilterActive.Location = new System.Drawing.Point( 84, 62);118 this.lblFilterActive.Location = new System.Drawing.Point(203, 31); 106 119 this.lblFilterActive.Name = "lblFilterActive"; 107 120 this.lblFilterActive.Size = new System.Drawing.Size(277, 13); … … 110 123 this.lblFilterActive.Visible = false; 111 124 // 112 // applyComboBox113 //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 // exportLabel128 //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 //136 125 // redoButton 137 126 // 138 127 this.redoButton.Enabled = false; 139 128 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); 141 130 this.redoButton.Name = "redoButton"; 142 131 this.redoButton.Size = new System.Drawing.Size(24, 24); … … 145 134 this.redoButton.UseVisualStyleBackColor = true; 146 135 // 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 // 147 216 // viewShortcutListView 148 217 // … … 152 221 this.viewShortcutListView.Caption = "ViewShortcutCollection View"; 153 222 this.viewShortcutListView.Content = null; 154 this.viewShortcutListView.Location = new System.Drawing.Point(4, 86);223 this.viewShortcutListView.Location = new System.Drawing.Point(4, 56); 155 224 this.viewShortcutListView.Name = "viewShortcutListView"; 156 225 this.viewShortcutListView.ReadOnly = false; 157 this.viewShortcutListView.Size = new System.Drawing.Size(831, 3 60);226 this.viewShortcutListView.Size = new System.Drawing.Size(831, 390); 158 227 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); 159 238 // 160 239 // DataPreprocessingView … … 162 241 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 163 242 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); 166 246 this.Controls.Add(this.exportProblemButton); 167 this.Controls.Add(this.applyInNewTabButton); 247 this.Controls.Add(this.undoButton); 248 this.Controls.Add(this.redoButton); 168 249 this.Controls.Add(this.lblFilterActive); 169 250 this.Controls.Add(this.viewShortcutListView); 170 this.Controls.Add(this.redoButton);171 this.Controls.Add(this.undoButton);172 251 this.Name = "DataPreprocessingView"; 173 252 this.Size = new System.Drawing.Size(838, 449); 174 this.Controls.SetChildIndex(this.undoButton, 0);175 this.Controls.SetChildIndex(this.redoButton, 0);176 253 this.Controls.SetChildIndex(this.viewShortcutListView, 0); 177 254 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); 178 263 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);185 264 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 265 this.newProblemDataTypeContextMenuStrip.ResumeLayout(false); 266 this.importProblemDataTypeContextMenuStrip.ResumeLayout(false); 186 267 this.ResumeLayout(false); 187 268 this.PerformLayout(); … … 196 277 private ViewShortcutListView viewShortcutListView; 197 278 private System.Windows.Forms.Label lblFilterActive; 198 private System.Windows.Forms.Label exportLabel;199 279 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; 201 292 } 202 293 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessorStarter.cs
r13502 r13508 34 34 IDataAnalysisProblem problem; 35 35 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); 37 37 MainFormManager.MainForm.ShowContent(context); 38 38 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj
r13502 r13508 255 255 <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project> 256 256 <Name>HeuristicLab.Collections-3.3</Name> 257 <Private>False</Private> 257 258 </ProjectReference> 258 259 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj"> … … 309 310 <Project>{C664305E-497C-4533-A140-967DEDB05C19}</Project> 310 311 <Name>HeuristicLab.Optimizer-3.3</Name> 312 <Private>False</Private> 311 313 </ProjectReference> 312 314 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> … … 323 325 <Project>{df87c13e-a889-46ff-8153-66dcaa8c5674}</Project> 324 326 <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> 325 342 <Private>False</Private> 326 343 </ProjectReference> -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/Plugin.cs.frame
r13504 r13508 44 44 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 45 45 [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")] 46 49 [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")] 47 50 public class HeuristicLabDataPreprocessingViewPlugin : PluginBase { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/CorrelationMatrixContent.cs
r13507 r13508 21 21 22 22 using System.Drawing; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 40 39 public DataAnalysisProblemData ProblemData { 41 40 get { 42 // ToDo: avoid iterating 43 return Context.ExportPossibilities.Select(p => p.Value()).OfType<DataAnalysisProblemData>().Single(); 41 return (DataAnalysisProblemData)Context.CreateNewProblemData(); 44 42 //var creator = new ProblemDataCreator(Context); 45 43 //return (DataAnalysisProblemData)creator.CreateProblemData(); -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs
r13507 r13508 11 11 } 12 12 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; } 15 15 16 16 public DataCompletenessChartContent(SearchLogic searchLogic) { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs
r13507 r13508 38 38 } 39 39 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; } 42 42 43 43 public int Rows { … … 97 97 98 98 99 public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {99 public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) { 100 100 ManipulationLogic = theManipulationLogic; 101 101 FilterLogic = theFilterLogic; -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/FilterContent.cs
r13507 r13508 35 35 private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>(); 36 36 37 public IFilterLogic FilterLogic { get; private set; }37 public FilterLogic FilterLogic { get; private set; } 38 38 39 39 public ICheckedItemCollection<IFilter> Filters { … … 56 56 } 57 57 58 public FilterContent( IFilterLogic filterLogic) {58 public FilterContent(FilterLogic filterLogic) { 59 59 FilterLogic = filterLogic; 60 60 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/IDataGridContent.cs
r13507 r13508 26 26 public interface IDataGridContent : IStringConvertibleMatrix { 27 27 ITransactionalPreprocessingData PreProcessingData { get; } 28 IManipulationLogic ManipulationLogic { get; }29 IFilterLogic FilterLogic { get; }28 ManipulationLogic ManipulationLogic { get; } 29 FilterLogic FilterLogic { get; } 30 30 31 31 IDictionary<int, IList<int>> Selection { get; set; } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs
r13507 r13508 29 29 public class ManipulationContent : Item, IViewShortcut { 30 30 31 private IManipulationLogic manipulationLogic;32 private ISearchLogic searchLogic;33 private IFilterLogic filterLogic;31 private ManipulationLogic manipulationLogic; 32 private SearchLogic searchLogic; 33 private FilterLogic filterLogic; 34 34 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; } } 38 38 39 39 public static new Image StaticItemImage { … … 41 41 } 42 42 43 public ManipulationContent( IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFilterLogic) {43 public ManipulationContent(ManipulationLogic theManipulationLogic, SearchLogic theSearchLogic, FilterLogic theFilterLogic) { 44 44 manipulationLogic = theManipulationLogic; 45 45 searchLogic = theSearchLogic; -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/StatisticsContent.cs
r13507 r13508 28 28 public class StatisticsContent : Item, IViewShortcut { 29 29 30 private readonly IStatisticsLogic statisticsLogic;31 public StatisticsContent( IStatisticsLogic theStatisticsLogic) {30 private readonly StatisticsLogic statisticsLogic; 31 public StatisticsContent(StatisticsLogic theStatisticsLogic) { 32 32 statisticsLogic = theStatisticsLogic; 33 33 } … … 38 38 } 39 39 40 public IStatisticsLogic StatisticsLogic {40 public StatisticsLogic StatisticsLogic { 41 41 get { return statisticsLogic; } 42 42 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/TransformationContent.cs
r13507 r13508 30 30 31 31 public IPreprocessingData Data { get; private set; } 32 public IFilterLogic FilterLogic { get; private set; }32 public FilterLogic FilterLogic { get; private set; } 33 33 34 34 public ICheckedItemList<ITransformation> CheckedTransformationList { get; private set; } … … 38 38 } 39 39 40 public TransformationContent(IPreprocessingData data, IFilterLogic filterLogic) {40 public TransformationContent(IPreprocessingData data, FilterLogic filterLogic) { 41 41 Data = data; 42 42 CheckedTransformationList = new CheckedItemList<ITransformation>(); -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r13502 r13508 78 78 </ItemGroup> 79 79 <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" /> 90 90 <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" /> 107 103 <Compile Include="ProblemDataCreator.cs" /> 108 104 <None Include="Plugin.cs.frame" /> 109 <Compile Include=" Implementations\DataGridContent.cs" />105 <Compile Include="Content\DataGridContent.cs" /> 110 106 <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" /> 118 112 <Compile Include="Plugin.cs" /> 119 113 <Compile Include="Properties\AssemblyInfo.cs" /> … … 162 156 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> 163 157 <Name>HeuristicLab.Persistence-3.3</Name> 158 <Private>False</Private> 164 159 </ProjectReference> 165 160 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs
r13507 r13508 26 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 public class FilterLogic : IFilterLogic{28 public class FilterLogic { 29 29 30 30 public IFilteredPreprocessingData PreprocessingData { get; private set; } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs
r13507 r13508 26 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 public class ManipulationLogic : IManipulationLogic{28 public class ManipulationLogic { 29 29 private readonly ITransactionalPreprocessingData preprocessingData; 30 private readonly IStatisticsLogic statisticsLogic;31 private readonly ISearchLogic searchLogic;30 private readonly StatisticsLogic statisticsLogic; 31 private readonly SearchLogic searchLogic; 32 32 33 33 public IEnumerable<string> VariableNames { … … 39 39 } 40 40 41 public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic) {41 public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, SearchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) { 42 42 preprocessingData = _prepocessingData; 43 43 searchLogic = theSearchLogic; … … 51 51 } 52 52 53 public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection ) {53 public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) { 54 54 preprocessingData.InTransaction(() => { 55 55 foreach (var column in cells) { … … 65 65 } 66 66 67 public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection ) {67 public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) { 68 68 preprocessingData.InTransaction(() => { 69 69 foreach (var column in cells) { … … 79 79 } 80 80 81 public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection ) {81 public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) { 82 82 preprocessingData.InTransaction(() => { 83 83 Random r = new Random(); … … 209 209 } 210 210 211 public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection ) {211 public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) { 212 212 preprocessingData.InTransaction(() => { 213 213 foreach (var column in cells) { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/SearchLogic.cs
r13507 r13508 25 25 26 26 namespace HeuristicLab.DataPreprocessing { 27 public class SearchLogic : ISearchLogic{27 public class SearchLogic { 28 28 private readonly ITransactionalPreprocessingData preprocessingData; 29 private readonly IFilterLogic filterLogic;29 private readonly FilterLogic filterLogic; 30 30 31 31 private Dictionary<int, IList<int>> MissingValueIndicies { get; set; } … … 44 44 } 45 45 46 public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, IFilterLogic theFilterLogic) {46 public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, FilterLogic theFilterLogic) { 47 47 preprocessingData = thePreprocessingData; 48 48 filterLogic = theFilterLogic; -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs
r13507 r13508 26 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 public class StatisticsLogic : IStatisticsLogic{28 public class StatisticsLogic { 29 29 30 30 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) { 34 34 preprocessingData = thePreprocessingData; 35 35 searchLogic = theSearchLogic; … … 71 71 } 72 72 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> { 74 74 var min = default(T); 75 75 if (preprocessingData.VariableHasType<T>(columnIndex)) { … … 82 82 } 83 83 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> { 85 85 var max = default(T); 86 86 if (preprocessingData.VariableHasType<T>(columnIndex)) { … … 93 93 } 94 94 95 public double GetMedian(int columnIndex, bool considerSelection ) {95 public double GetMedian(int columnIndex, bool considerSelection = false) { 96 96 double median = double.NaN; 97 97 if (preprocessingData.VariableHasType<double>(columnIndex)) { … … 104 104 } 105 105 106 public double GetAverage(int columnIndex, bool considerSelection ) {106 public double GetAverage(int columnIndex, bool considerSelection = false) { 107 107 double avg = double.NaN; 108 108 if (preprocessingData.VariableHasType<double>(columnIndex)) { … … 115 115 } 116 116 117 public DateTime GetMedianDateTime(int columnIndex, bool considerSelection ) {117 public DateTime GetMedianDateTime(int columnIndex, bool considerSelection = false) { 118 118 DateTime median = new DateTime(); 119 119 if (preprocessingData.VariableHasType<DateTime>(columnIndex)) { … … 123 123 } 124 124 125 public DateTime GetAverageDateTime(int columnIndex, bool considerSelection ) {125 public DateTime GetAverageDateTime(int columnIndex, bool considerSelection = false) { 126 126 DateTime avg = new DateTime(); 127 127 if (preprocessingData.VariableHasType<DateTime>(columnIndex)) { … … 131 131 } 132 132 133 public T GetMostCommonValue<T>(int columnIndex, bool considerSelection ) {133 public T GetMostCommonValue<T>(int columnIndex, bool considerSelection = false) { 134 134 var values = GetValuesWithoutNaN<T>(columnIndex, considerSelection); 135 135 if (!values.Any()) -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/PreprocessingContext.cs
r13507 r13508 35 35 public string Filename { get; set; } 36 36 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 CSV52 }53 }54 public bool CanExport {55 get { return Source is IAlgorithm || Source is IDataAnalysisProblem || Source is IDataAnalysisProblemData; }56 }57 58 37 [Storable] 59 38 public IFilteredPreprocessingData Data { get; private set; } … … 62 41 private IItem Source { get; set; } 63 42 43 public event EventHandler Reset; 64 44 65 public PreprocessingContext() : this(new RegressionProblemData()) { 66 Name = "Data Preprocessing"; 45 #region Constructors 46 public PreprocessingContext() 47 : this(new RegressionProblemData()) { 67 48 } 68 public PreprocessingContext(I Item source)49 public PreprocessingContext(IDataAnalysisProblemData problemData, IItem source = null) 69 50 : base("Data Preprocessing") { 70 Import(source); 51 if (problemData == null) throw new ArgumentNullException("problemData"); 52 Import(problemData, source); 71 53 } 72 54 … … 79 61 Data = cloner.Clone(original.Data); 80 62 } 81 82 63 public override IDeepCloneable Clone(Cloner cloner) { 83 64 return new PreprocessingContext(this, cloner); 84 65 } 66 #endregion 85 67 86 68 #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)? 94 82 } 95 96 83 private IDataAnalysisProblemData ExtractProblemData(IItem source) { 97 84 var algorithm = source as Algorithm; … … 103 90 104 91 #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; } 113 94 } 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 114 115 private IAlgorithm ExportAlgorithm(IAlgorithm source) { 115 116 var preprocessedAlgorithm = (IAlgorithm)source.Clone(); … … 117 118 preprocessedAlgorithm.Runs.Clear(); 118 119 var problem = (IDataAnalysisProblem)preprocessedAlgorithm.Problem; 119 SetNewProblemData(problem);120 problem.ProblemDataParameter.ActualValue = CreateNewProblemData(); 120 121 return preprocessedAlgorithm; 121 122 } 122 123 private IDataAnalysisProblem ExportProblem(IDataAnalysisProblem source) { 123 124 var preprocessedProblem = (IDataAnalysisProblem)source.Clone(); 124 SetNewProblemData(preprocessedProblem);125 preprocessedProblem.ProblemDataParameter.ActualValue = CreateNewProblemData(); 125 126 return preprocessedProblem; 126 127 } 127 128 private IDataAnalysisProblemData ExportProblemData(IDataAnalysisProblemData source) { 129 return CreateNewProblemData(); 130 } 131 132 public IDataAnalysisProblemData CreateNewProblemData() { 128 133 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; 137 138 } 138 139 #endregion 140 141 protected virtual void OnReset() { 142 if (Reset != null) 143 Reset(this, EventArgs.Empty); 144 } 139 145 } 140 146 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs
r13502 r13508 48 48 IDataAnalysisProblemData problemData; 49 49 50 if (oldProblemData is RegressionProblemData) { 50 if (oldProblemData is TimeSeriesPrognosisProblemData) { 51 problemData = CreateTimeSeriesPrognosisData((TimeSeriesPrognosisProblemData)oldProblemData); 52 } else if (oldProblemData is RegressionProblemData) { 51 53 problemData = CreateRegressionData((RegressionProblemData)oldProblemData); 52 54 } else if (oldProblemData is ClassificationProblemData) { … … 69 71 } 70 72 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 71 85 private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) { 72 86 var targetVariable = oldProblemData.TargetVariable; … … 83 97 targetVariable = context.Data.VariableNames.First(); 84 98 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 }; 87 102 return newProblemData; 88 103 }
Note: See TracChangeset
for help on using the changeset viewer.