Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 10221 was 10221, checked in by pfleck, 11 years ago
  • Cloned Algorithm and swapped Dataset an other members of the DataAnalysisProblemData
  • Refactored GetMostOuterContent
File size: 2.8 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.Problems.DataAnalysis;
31
32namespace HeuristicLab.DataPreprocessing {
33  [View("Data Preprocessing View")]
34  [Content(typeof(IPreprocessingContext), false)]
35  [Content(typeof(PreprocessingContext), true)]
36  public partial class DataPreprocessingView : ItemView {
37
38    public new IPreprocessingContext Content {
39      get { return (IPreprocessingContext)base.Content; }
40      set { base.Content = value; }
41    }
42
43    public DataPreprocessingView() {
44      InitializeComponent();
45    }
46
47    protected override void OnContentChanged() {
48      base.OnContentChanged();
49    }
50
51    private void button1_Click(object sender, System.EventArgs e) {
52
53      IPreprocessingData Data = Content.Data;
54
55      foreach (string variable in Data.VariableNames) {
56        for (int j = 0; j < Data.Rows; j++) {
57          // assume: all double
58          Data.SetCell(variable, j, 1.0);
59        }
60      }
61
62      MessageBox.Show("Success, now cloning... ");
63
64      Dataset dataset = Data.ExportToDataset();
65      var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
66
67      var cloner = new Cloner();
68
69      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset);
70      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition);
71      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition);
72      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables);
73
74      var item = cloner.Clone(Content.ParentItem);
75
76      MainFormManager.MainForm.ShowContent(item);
77
78      //var clone = null;
79
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.