Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4
Files:
1 added
6 edited

Legend:

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

    r15846 r15865  
    2929
    3030namespace HeuristicLab.DataPreprocessing {
     31
    3132  [Item("Transformation", "Represents the transformation grid.")]
    3233  [StorableClass]
     
    3738
    3839    [Storable]
    39     public ICheckedItemList<IDataAnalysisTransformation> CheckedTransformationList { get; private set; }
     40    public IItemList<PreprocessingTransformation> TransformationList { get; private set; }
    4041
    4142    #region Constructor, Cloning & Persistence
    4243    public TransformationContent(IFilteredPreprocessingData preprocessingData)
    4344      : base(preprocessingData) {
    44       CheckedTransformationList = new CheckedItemList<IDataAnalysisTransformation>();
     45      TransformationList = new ItemList<PreprocessingTransformation>();
    4546    }
    4647
    4748    public TransformationContent(TransformationContent original, Cloner cloner)
    4849      : base(original, cloner) {
    49       CheckedTransformationList = cloner.Clone(original.CheckedTransformationList);
     50      TransformationList = cloner.Clone(original.TransformationList);
    5051    }
    5152    public override IDeepCloneable Clone(Cloner cloner) {
     
    5960
    6061    public bool ApplyTransformations(out IEnumerable<string> errorMessages) {
    61       var transformations = CheckedTransformationList.CheckedItems.Select(x => x.Value);
    62 
    6362      bool success = true;
    6463      var errors = new List<string>();
    6564      errorMessages = errors;
    6665
    67       foreach (var transformation in transformations) {
     66      foreach (var transformation in TransformationList.Where(x => !x.IsApplied)) {
    6867        var sourceVariable = transformation.OriginalVariable;
    6968        var targetVariable = transformation.TransformedVariable ?? sourceVariable + " Transformed";
     
    8685
    8786          PreprocessingData.Transformations.Add(transformation);
    88           CheckedTransformationList.SetItemCheckedState(transformation, false);
     87          transformation.IsApplied = true;
     88          // TODO: remove unused valid values in constrainedParameters
    8989        } else {
    9090          success = false;
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs

    r15846 r15865  
    204204
    205205    #region Transformations
    206     public IList<IDataAnalysisTransformation> Transformations {
     206    public IList<PreprocessingTransformation> Transformations {
    207207      get { return originalData.Transformations; }
    208208    }
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs

    r15846 r15865  
    7878
    7979    #region Transformations
    80     IList<IDataAnalysisTransformation> Transformations { get; }
     80    IList<PreprocessingTransformation> Transformations { get; }
    8181    #endregion
    8282
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r15846 r15865  
    4747      Name = "Preprocessing Data";
    4848
    49       Transformations = new List<IDataAnalysisTransformation>();
     49      Transformations = new List<PreprocessingTransformation>();
    5050      selection = new Dictionary<int, IList<int>>();
    5151
     
    6161      TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner);
    6262      TestPartition = (IntRange)original.TestPartition.Clone(cloner);
    63       Transformations = new List<IDataAnalysisTransformation>(original.Transformations.Select(cloner.Clone));
     63      Transformations = new List<PreprocessingTransformation>(original.Transformations.Select(cloner.Clone));
    6464
    6565      InputVariables = new List<string>(original.InputVariables);
     
    350350    #region Transformations
    351351    [Storable]
    352     public IList<IDataAnalysisTransformation> Transformations { get; protected set; }
     352    public IList<PreprocessingTransformation> Transformations { get; protected set; }
    353353    #endregion
    354354
     
    414414      }
    415415
     416      // TODO: set fixed constrained (allowed) values
     417      foreach (var trans in problemData.Transformations) {
     418        var newTrans = new PreprocessingTransformation(variableNames.Select(x => new StringValue(x))) {
     419          OriginalVariable = trans.OriginalVariable,
     420          TransformedVariable = trans.TransformedVariable,
     421          IsApplied = true
     422        };
     423        var cloned = (ITransformation)trans.Transformation.Clone();
     424        newTrans.TransformationParameter.ValidValues.Add(cloned);
     425        newTrans.Transformation = cloned;
     426        Transformations.Add(newTrans);
     427      }
     428
    416429      TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End);
    417430      TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End);
     
    459472      public IntRange TrainingPartition { get; set; }
    460473      public IntRange TestPartition { get; set; }
    461       public IList<IDataAnalysisTransformation> Transformations { get; set; }
     474      public IList<PreprocessingTransformation> Transformations { get; set; }
    462475      public DataPreprocessingChangedEventType ChangedType { get; set; }
    463476
     
    487500        TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End),
    488501        TestPartition = new IntRange(TestPartition.Start, TestPartition.End),
    489         Transformations = new List<IDataAnalysisTransformation>(Transformations),
     502        Transformations = new List<PreprocessingTransformation>(Transformations),
    490503        ChangedType = changedType,
    491504        ChangedColumn = column,
     
    682695      l = 0;
    683696      ir = n - 1;
    684       for (;;) {
     697      for (; ; ) {
    685698        if (ir <= l + 1) {
    686699          // Active partition contains 1 or 2 elements.
     
    707720          j = ir;
    708721          a = arr[l + 1]; // Partitioning element.
    709           for (;;) { // Beginning of innermost loop.
     722          for (; ; ) { // Beginning of innermost loop.
    710723            do i++; while (arr[i].CompareTo(a) < 0); // Scan up to find element > a.
    711724            do j--; while (arr[j].CompareTo(a) > 0); // Scan down to find element < a.
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r15846 r15865  
    107107      <Private>False</Private>
    108108    </Reference>
     109    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     110      <SpecificVersion>False</SpecificVersion>
     111      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     112    </Reference>
    109113    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    110114      <SpecificVersion>False</SpecificVersion>
     
    134138    <Compile Include="Content\MultiScatterPlotContent.cs" />
    135139    <Compile Include="Content\PreprocessingContent.cs" />
     140    <Compile Include="Data\PreprocessingTransformation.cs" />
    136141    <Compile Include="Content\SingleScatterPlotContent.cs" />
    137142    <Compile Include="Content\ScatterPlotContent.cs" />
  • 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.