Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10221


Ignore:
Timestamp:
12/11/13 17:21:25 (9 years ago)
Author:
pfleck
Message:
  • Cloned Algorithm and swapped Dataset an other members of the DataAnalysisProblemData
  • Refactored GetMostOuterContent
Location:
branches/DataPreprocessing
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/DataPreprocessingView.cs

    r10220 r10221  
    1 using System.Windows.Forms;
     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;
    226using HeuristicLab.Core.Views;
     27using HeuristicLab.Data;
    328using HeuristicLab.MainForm;
    429using HeuristicLab.MainForm.WindowsForms;
     30using HeuristicLab.Problems.DataAnalysis;
    531
    632namespace HeuristicLab.DataPreprocessing {
     
    3662      MessageBox.Show("Success, now cloning... ");
    3763
     64      Dataset dataset = Data.ExportToDataset();
     65      var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
    3866
    39       //Dataset ds = Data.ExportToDataset();
    40       //var cloner = new Cloner();
     67      var cloner = new Cloner();
    4168
    42       //cloner.RegisterClonedObject()
     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);
    4377
    4478      //var clone = null;
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10219 r10221  
    9999  </ItemGroup>
    100100  <ItemGroup>
     101    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
     102      <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project>
     103      <Name>HeuristicLab.Collections-3.3</Name>
     104    </ProjectReference>
    101105    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    102106      <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingContext.cs

    r10219 r10221  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Problems.DataAnalysis;
    2425
    2526namespace HeuristicLab.DataPreprocessing {
    2627  [Item("PreprocessingContext", "PreprocessingContext")]
    2728  public class PreprocessingContext : Item, IPreprocessingContext {
    28     public PreprocessingContext(IPreprocessingData data, IItem parentItem) {
     29    public PreprocessingContext(IPreprocessingData data, IItem parentItem, IDataAnalysisProblemData dataAnalysisProblemData) {
    2930      Data = data;
    3031      ParentItem = parentItem;
     32      DataAnalysisProblemData = dataAnalysisProblemData;
    3133    }
    3234
     
    3537      Data = cloner.Clone(original.Data);
    3638      ParentItem = original.ParentItem;
     39      DataAnalysisProblemData = original.DataAnalysisProblemData;
    3740    }
    3841
     
    4447    public IItem ParentItem { get; private set; }
    4548
     49    public IDataAnalysisProblemData DataAnalysisProblemData { get; private set; }
     50
    4651    public override IDeepCloneable Clone(Cloner cloner) {
    4752      return new PreprocessingContext(this, cloner);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10220 r10221  
    142142    }
    143143
     144    public IntRange TrainingPartition {
     145      get { return new IntRange(0, (int)(Rows * trainingToTestRatio)); }
     146    }
     147
     148    public IntRange TestPartition {
     149      get { return new IntRange((int)(Rows * trainingToTestRatio), Math.Max(Rows - 1, 0)); }
     150    }
     151
    144152    public IEnumerable<string> VariableNames {
    145153      get { return variableNames; }
     
    155163
    156164    public int Rows {
    157       get { return variableValues.Count; }
     165      get { return variableValues[variableNames[0]].Count; }
    158166    }
    159167    public IDictionary<string, IEnumerable<int>> GetMissingValueIndices() {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingContext.cs

    r10219 r10221  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Problems.DataAnalysis;
    2324namespace HeuristicLab.DataPreprocessing {
    2425  public interface IPreprocessingContext : IItem {
     
    2930    /// </summary>
    3031    IItem ParentItem { get; }
     32
     33    IDataAnalysisProblemData DataAnalysisProblemData { get; }
    3134  }
    3235}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10220 r10221  
    4040    void DeleteColumn(string variableName);
    4141
     42    IntRange TrainingPartition { get; }
     43    IntRange TestPartition { get; }
     44
    4245    IEnumerable<string> VariableNames { get; }
    4346    bool IsType<T>(string variableName);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Plugin.cs.frame

    r10134 r10221  
    3131  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3232  [PluginDependency("HeuristicLab.Core", "3.3")]
     33  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3334  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3435  [PluginDependency("HeuristicLab.MainForm", "3.3")]
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.cs

    r10219 r10221  
    3030using HeuristicLab.MainForm;
    3131using HeuristicLab.MainForm.WindowsForms;
    32 using HeuristicLab.Optimization.Views;
    3332
    3433namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    104103
    105104    private void DataPreprocessingButton_Click(object sender, EventArgs e) {
    106       IItem parentItem = GetAlgorithmOrProblem();
     105      IItem parentItem = GetMostOuterContent();
    107106      var preprocessingData = new PreprocessingData(Content);
    108107
    109108      // TODO: ProblemDataView depends on DataPreprocessing
    110       var context = new PreprocessingContext(preprocessingData, parentItem);
     109      var context = new PreprocessingContext(preprocessingData, parentItem, Content);
    111110      MainFormManager.MainForm.ShowContent(context);
    112 
    113       //Type viewType = MainFormManager.GetViewTypes(this.Content.GetType(), true).FirstOrDefault(t => typeof(DataPreprocessingView).IsAssignableFrom(t));
    114       //MainFormManager.MainForm.ShowContent(Content, viewType);
    115111    }
    116112
    117     private IItem GetAlgorithmOrProblem() {
    118       Control a = this;
    119       IItem i = null;
     113    private IItem GetMostOuterContent() {
     114      Control control = this;
     115      ItemView itemView = null;
    120116      do {
    121         a = a.Parent;
    122       } while (a != null && !(a is ProblemView));
     117        control = control.Parent;
     118        if (control is ItemView)
     119          itemView = (ItemView)control;
     120      } while (control != null);
    123121
    124       if (a is ProblemView) {
    125         i = ((ProblemView)a).Content;
    126       }
    127 
    128       do {
    129         a = a.Parent;
    130       } while (a != null && !(a is AlgorithmView));
    131 
    132       if (a is AlgorithmView) {
    133         i = ((AlgorithmView)a).Content;
    134       }
    135 
    136       return i;
    137 
    138       //AlgorithmView algV = a as AlgorithmView;
    139       //var clone = (IContent)algV.Content.Clone(new Cloner());
    140       //MainFormManager.MainForm.ShowContent(clone);
    141 
     122      return itemView.Content;
    142123    }
    143124  }
Note: See TracChangeset for help on using the changeset viewer.