Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/14/16 17:51:48 (9 years ago)
Author:
pfleck
Message:

#2559

  • Enabled type selection for creating/importing/exporting/applying.
  • Deleted unnecessary interfaces.
  • Reorganized source files of DataPreprocessing.
Location:
trunk/sources/HeuristicLab.DataPreprocessing/3.4
Files:
3 added
3 deleted
3 edited
27 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/CorrelationMatrixContent.cs

    r13507 r13508  
    2121
    2222using System.Drawing;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4039    public DataAnalysisProblemData ProblemData {
    4140      get {
    42         // ToDo: avoid iterating
    43         return Context.ExportPossibilities.Select(p => p.Value()).OfType<DataAnalysisProblemData>().Single();
     41        return (DataAnalysisProblemData)Context.CreateNewProblemData();
    4442        //var creator = new ProblemDataCreator(Context);
    4543        //return (DataAnalysisProblemData)creator.CreateProblemData();
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs

    r13507 r13508  
    1111    }
    1212
    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; }
    1515
    1616    public DataCompletenessChartContent(SearchLogic searchLogic) {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs

    r13507 r13508  
    3838    }
    3939
    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; }
    4242
    4343    public int Rows {
     
    9797
    9898
    99     public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {
     99    public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) {
    100100      ManipulationLogic = theManipulationLogic;
    101101      FilterLogic = theFilterLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/FilterContent.cs

    r13507 r13508  
    3535    private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>();
    3636
    37     public IFilterLogic FilterLogic { get; private set; }
     37    public FilterLogic FilterLogic { get; private set; }
    3838
    3939    public ICheckedItemCollection<IFilter> Filters {
     
    5656    }
    5757
    58     public FilterContent(IFilterLogic filterLogic) {
     58    public FilterContent(FilterLogic filterLogic) {
    5959      FilterLogic = filterLogic;
    6060    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/IDataGridContent.cs

    r13507 r13508  
    2626  public interface IDataGridContent : IStringConvertibleMatrix {
    2727    ITransactionalPreprocessingData PreProcessingData { get; }
    28     IManipulationLogic ManipulationLogic { get; }
    29     IFilterLogic FilterLogic { get; }
     28    ManipulationLogic ManipulationLogic { get; }
     29    FilterLogic FilterLogic { get; }
    3030
    3131    IDictionary<int, IList<int>> Selection { get; set; }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs

    r13507 r13508  
    2929  public class ManipulationContent : Item, IViewShortcut {
    3030
    31     private IManipulationLogic manipulationLogic;
    32     private ISearchLogic searchLogic;
    33     private IFilterLogic filterLogic;
     31    private ManipulationLogic manipulationLogic;
     32    private SearchLogic searchLogic;
     33    private FilterLogic filterLogic;
    3434
    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; } }
    3838
    3939    public static new Image StaticItemImage {
     
    4141    }
    4242
    43     public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFilterLogic) {
     43    public ManipulationContent(ManipulationLogic theManipulationLogic, SearchLogic theSearchLogic, FilterLogic theFilterLogic) {
    4444      manipulationLogic = theManipulationLogic;
    4545      searchLogic = theSearchLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/StatisticsContent.cs

    r13507 r13508  
    2828  public class StatisticsContent : Item, IViewShortcut {
    2929
    30     private readonly IStatisticsLogic statisticsLogic;
    31     public StatisticsContent(IStatisticsLogic theStatisticsLogic) {
     30    private readonly StatisticsLogic statisticsLogic;
     31    public StatisticsContent(StatisticsLogic theStatisticsLogic) {
    3232      statisticsLogic = theStatisticsLogic;
    3333    }
     
    3838    }
    3939
    40     public IStatisticsLogic StatisticsLogic {
     40    public StatisticsLogic StatisticsLogic {
    4141      get { return statisticsLogic; }
    4242    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/TransformationContent.cs

    r13507 r13508  
    3030
    3131    public IPreprocessingData Data { get; private set; }
    32     public IFilterLogic FilterLogic { get; private set; }
     32    public FilterLogic FilterLogic { get; private set; }
    3333
    3434    public ICheckedItemList<ITransformation> CheckedTransformationList { get; private set; }
     
    3838    }
    3939
    40     public TransformationContent(IPreprocessingData data, IFilterLogic filterLogic) {
     40    public TransformationContent(IPreprocessingData data, FilterLogic filterLogic) {
    4141      Data = data;
    4242      CheckedTransformationList = new CheckedItemList<ITransformation>();
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r13502 r13508  
    7878  </ItemGroup>
    7979  <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" />
    9090    <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" />
    107103    <Compile Include="ProblemDataCreator.cs" />
    108104    <None Include="Plugin.cs.frame" />
    109     <Compile Include="Implementations\DataGridContent.cs" />
     105    <Compile Include="Content\DataGridContent.cs" />
    110106    <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" />
    118112    <Compile Include="Plugin.cs" />
    119113    <Compile Include="Properties\AssemblyInfo.cs" />
     
    162156      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    163157      <Name>HeuristicLab.Persistence-3.3</Name>
     158      <Private>False</Private>
    164159    </ProjectReference>
    165160    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class FilterLogic : IFilterLogic {
     28  public class FilterLogic {
    2929
    3030    public IFilteredPreprocessingData PreprocessingData { get; private set; }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class ManipulationLogic : IManipulationLogic {
     28  public class ManipulationLogic {
    2929    private readonly ITransactionalPreprocessingData preprocessingData;
    30     private readonly IStatisticsLogic statisticsLogic;
    31     private readonly ISearchLogic searchLogic;
     30    private readonly StatisticsLogic statisticsLogic;
     31    private readonly SearchLogic searchLogic;
    3232
    3333    public IEnumerable<string> VariableNames {
     
    3939    }
    4040
    41     public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic) {
     41    public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, SearchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {
    4242      preprocessingData = _prepocessingData;
    4343      searchLogic = theSearchLogic;
     
    5151    }
    5252
    53     public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     53    public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    5454      preprocessingData.InTransaction(() => {
    5555        foreach (var column in cells) {
     
    6565    }
    6666
    67     public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     67    public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    6868      preprocessingData.InTransaction(() => {
    6969        foreach (var column in cells) {
     
    7979    }
    8080
    81     public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     81    public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    8282      preprocessingData.InTransaction(() => {
    8383        Random r = new Random();
     
    209209    }
    210210
    211     public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection) {
     211    public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    212212      preprocessingData.InTransaction(() => {
    213213        foreach (var column in cells) {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/SearchLogic.cs

    r13507 r13508  
    2525
    2626namespace HeuristicLab.DataPreprocessing {
    27   public class SearchLogic : ISearchLogic {
     27  public class SearchLogic {
    2828    private readonly ITransactionalPreprocessingData preprocessingData;
    29     private readonly IFilterLogic filterLogic;
     29    private readonly FilterLogic filterLogic;
    3030
    3131    private Dictionary<int, IList<int>> MissingValueIndicies { get; set; }
     
    4444    }
    4545
    46     public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, IFilterLogic theFilterLogic) {
     46    public SearchLogic(ITransactionalPreprocessingData thePreprocessingData, FilterLogic theFilterLogic) {
    4747      preprocessingData = thePreprocessingData;
    4848      filterLogic = theFilterLogic;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs

    r13507 r13508  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28   public class StatisticsLogic : IStatisticsLogic {
     28  public class StatisticsLogic {
    2929
    3030    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) {
    3434      preprocessingData = thePreprocessingData;
    3535      searchLogic = theSearchLogic;
     
    7171    }
    7272
    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> {
    7474      var min = default(T);
    7575      if (preprocessingData.VariableHasType<T>(columnIndex)) {
     
    8282    }
    8383
    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> {
    8585      var max = default(T);
    8686      if (preprocessingData.VariableHasType<T>(columnIndex)) {
     
    9393    }
    9494
    95     public double GetMedian(int columnIndex, bool considerSelection) {
     95    public double GetMedian(int columnIndex, bool considerSelection = false) {
    9696      double median = double.NaN;
    9797      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    104104    }
    105105
    106     public double GetAverage(int columnIndex, bool considerSelection) {
     106    public double GetAverage(int columnIndex, bool considerSelection = false) {
    107107      double avg = double.NaN;
    108108      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    115115    }
    116116
    117     public DateTime GetMedianDateTime(int columnIndex, bool considerSelection) {
     117    public DateTime GetMedianDateTime(int columnIndex, bool considerSelection = false) {
    118118      DateTime median = new DateTime();
    119119      if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
     
    123123    }
    124124
    125     public DateTime GetAverageDateTime(int columnIndex, bool considerSelection) {
     125    public DateTime GetAverageDateTime(int columnIndex, bool considerSelection = false) {
    126126      DateTime avg = new DateTime();
    127127      if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
     
    131131    }
    132132
    133     public T GetMostCommonValue<T>(int columnIndex, bool considerSelection) {
     133    public T GetMostCommonValue<T>(int columnIndex, bool considerSelection = false) {
    134134      var values = GetValuesWithoutNaN<T>(columnIndex, considerSelection);
    135135      if (!values.Any())
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/PreprocessingContext.cs

    r13507 r13508  
    3535    public string Filename { get; set; }
    3636
    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 CSV
    52       }
    53     }
    54     public bool CanExport {
    55       get { return Source is IAlgorithm || Source is IDataAnalysisProblem || Source is IDataAnalysisProblemData; }
    56     }
    57 
    5837    [Storable]
    5938    public IFilteredPreprocessingData Data { get; private set; }
     
    6241    private IItem Source { get; set; }
    6342
     43    public event EventHandler Reset;
    6444
    65     public PreprocessingContext() : this(new RegressionProblemData()) {
    66       Name = "Data Preprocessing";
     45    #region Constructors
     46    public PreprocessingContext()
     47      : this(new RegressionProblemData()) {
    6748    }
    68     public PreprocessingContext(IItem source)
     49    public PreprocessingContext(IDataAnalysisProblemData problemData, IItem source = null)
    6950      : base("Data Preprocessing") {
    70       Import(source);
     51      if (problemData == null) throw new ArgumentNullException("problemData");
     52      Import(problemData, source);
    7153    }
    7254
     
    7961      Data = cloner.Clone(original.Data);
    8062    }
    81 
    8263    public override IDeepCloneable Clone(Cloner cloner) {
    8364      return new PreprocessingContext(this, cloner);
    8465    }
     66    #endregion
    8567
    8668    #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)?
    9482    }
    95 
    9683    private IDataAnalysisProblemData ExtractProblemData(IItem source) {
    9784      var algorithm = source as Algorithm;
     
    10390
    10491    #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; }
    11394    }
     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
    114115    private IAlgorithm ExportAlgorithm(IAlgorithm source) {
    115116      var preprocessedAlgorithm = (IAlgorithm)source.Clone();
     
    117118      preprocessedAlgorithm.Runs.Clear();
    118119      var problem = (IDataAnalysisProblem)preprocessedAlgorithm.Problem;
    119       SetNewProblemData(problem);
     120      problem.ProblemDataParameter.ActualValue = CreateNewProblemData();
    120121      return preprocessedAlgorithm;
    121122    }
    122123    private IDataAnalysisProblem ExportProblem(IDataAnalysisProblem source) {
    123124      var preprocessedProblem = (IDataAnalysisProblem)source.Clone();
    124       SetNewProblemData(preprocessedProblem);
     125      preprocessedProblem.ProblemDataParameter.ActualValue = CreateNewProblemData();
    125126      return preprocessedProblem;
    126127    }
    127128    private IDataAnalysisProblemData ExportProblemData(IDataAnalysisProblemData source) {
     129      return CreateNewProblemData();
     130    }
     131
     132    public IDataAnalysisProblemData CreateNewProblemData() {
    128133      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;
    137138    }
    138139    #endregion
     140
     141    protected virtual void OnReset() {
     142      if (Reset != null)
     143        Reset(this, EventArgs.Empty);
     144    }
    139145  }
    140146}
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r13502 r13508  
    4848      IDataAnalysisProblemData problemData;
    4949
    50       if (oldProblemData is RegressionProblemData) {
     50      if (oldProblemData is TimeSeriesPrognosisProblemData) {
     51        problemData = CreateTimeSeriesPrognosisData((TimeSeriesPrognosisProblemData)oldProblemData);
     52      } else if (oldProblemData is RegressionProblemData) {
    5153        problemData = CreateRegressionData((RegressionProblemData)oldProblemData);
    5254      } else if (oldProblemData is ClassificationProblemData) {
     
    6971    }
    7072
     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
    7185    private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) {
    7286      var targetVariable = oldProblemData.TargetVariable;
     
    8397        targetVariable = context.Data.VariableNames.First();
    8498      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      };
    87102      return newProblemData;
    88103    }
Note: See TracChangeset for help on using the changeset viewer.