Ignore:
Timestamp:
03/27/18 15:46:12 (3 years ago)
Author:
pfleck
Message:

#2906 Added PreprocessingTransformation as a custom view-model for transformations in preprocessing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r15856 r15865  
    3434    }
    3535
    36     private IList<IDataAnalysisTransformation> Transformations {
     36    private IList<PreprocessingTransformation> Transformations {
    3737      get { return context.Data.Transformations; }
    3838    }
     
    7676        targetVariable = context.Data.VariableNames.First();
    7777      var inputVariables = GetDoubleInputVariables(targetVariable);
    78       var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     78      var newProblemData = new TimeSeriesPrognosisProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) {
    7979        TrainingHorizon = oldProblemData.TrainingHorizon,
    8080        TestHorizon = oldProblemData.TestHorizon
     
    8585    private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) {
    8686      // TODO: transformations (additional inputs, target changed)
    87       var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, Transformations);
     87      var targetVariable = RegressionProblemData.GetTransformedTragetVariable(oldProblemData.TargetVariable, CreateDataAnalysisTransformation());
    8888      if (!context.Data.VariableNames.Contains(targetVariable))
    8989        targetVariable = context.Data.VariableNames.First();
    9090      var inputVariables = GetDoubleInputVariables(targetVariable);
    91       var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);
     91      var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation());
    9292      return newProblemData;
    9393    }
     
    9898        targetVariable = context.Data.VariableNames.First();
    9999      var inputVariables = GetDoubleInputVariables(targetVariable);
    100       var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations) {
     100      var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, CreateDataAnalysisTransformation()) {
    101101        PositiveClass = oldProblemData.PositiveClass
    102102      };
     
    105105
    106106    private IDataAnalysisProblemData CreateClusteringData(ClusteringProblemData oldProblemData) {
    107       return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), Transformations);
     107      return new ClusteringProblemData(ExportedDataset, GetDoubleInputVariables(String.Empty), CreateDataAnalysisTransformation());
    108108    }
    109109
     
    117117    }
    118118
    119      void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) {
    120        var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, Transformations);
     119    void SetAllowedInputVariables(IDataAnalysisProblemData problemData, IEnumerable<string> oldInputVariables) {
     120      var inputs = DataAnalysisProblemData.ExtendInputVariables(oldInputVariables, problemData.Transformations);
    121121
    122122      foreach (var input in problemData.InputVariables) {
     
    142142      return context.Data.TrainingPartition.End - context.Data.TrainingPartition.Start > 1 || list.Range() > 0;
    143143    }
     144
     145    private IEnumerable<IDataAnalysisTransformation> CreateDataAnalysisTransformation() {
     146      return Transformations.Select(x => new DataAnalysisTransformation(x.OriginalVariable, x.TransformedVariable, (ITransformation)x.Transformation.Clone()));
     147    }
    144148  }
    145149}
Note: See TracChangeset for help on using the changeset viewer.