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 |
|
---|
22 | using System.Linq;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Common;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using HeuristicLab.Core.Views;
|
---|
27 | using HeuristicLab.Data;
|
---|
28 | using HeuristicLab.MainForm;
|
---|
29 | using HeuristicLab.MainForm.WindowsForms;
|
---|
30 | using HeuristicLab.Problems.DataAnalysis;
|
---|
31 |
|
---|
32 | namespace 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 | }
|
---|