Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/DataPreprocessingView.cs @ 10248

Last change on this file since 10248 was 10240, checked in by pfleck, 11 years ago

Deleted Runs on Algorithm-Cloning for Preprocessing.

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Linq;
23using System.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Core.Views;
27using HeuristicLab.Data;
28using HeuristicLab.MainForm;
29using HeuristicLab.MainForm.WindowsForms;
30using HeuristicLab.Optimization;
31using HeuristicLab.Problems.DataAnalysis;
32
33namespace HeuristicLab.DataPreprocessing {
34  [View("Data Preprocessing View")]
35  [Content(typeof(IPreprocessingContext), false)]
36  [Content(typeof(PreprocessingContext), true)]
37  public partial class DataPreprocessingView : ItemView {
38
39    public new IPreprocessingContext Content {
40      get { return (IPreprocessingContext)base.Content; }
41      set { base.Content = value; }
42    }
43
44    public DataPreprocessingView() {
45      InitializeComponent();
46    }
47
48    protected override void OnContentChanged() {
49      base.OnContentChanged();
50    }
51
52    private void button1_Click(object sender, System.EventArgs e) {
53
54      IPreprocessingData Data = Content.Data;
55
56      foreach (string variable in Data.VariableNames) {
57        for (int j = 0; j < Data.Rows; j++) {
58          // assume: all double
59          Data.SetCell(variable, j, 1.0);
60        }
61      }
62
63      MessageBox.Show("Success, now cloning... ");
64
65      Dataset dataset = Data.ExportToDataset();
66      var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
67
68      var cloner = new Cloner();
69
70      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset);
71      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition);
72      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition);
73      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables);
74      if (Content.Algorithm != null) {
75        cloner.RegisterClonedObject(Content.Algorithm.Runs, new RunCollection { OptimizerName = Content.Algorithm.Name });
76      }
77
78      var item = cloner.Clone(Content.ParentItem);
79      MainFormManager.MainForm.ShowContent(item);
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.