Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/20/18 12:28:16 (7 years ago)
Author:
pfleck
Message:

#2906 Added TransformedModelView, implemented "remove virtual columns"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r15847 r15848  
    273273    }
    274274
    275     public static IDataset InverseTransform(IDataset dataset, IEnumerable<IDataAnalysisTransformation> transformations) {
     275    public static IDataset InverseTransform(IDataset dataset, IEnumerable<IDataAnalysisTransformation> transformations, bool removeVirtualVariables = true) {
    276276      var modifiableDataset = ((Dataset)dataset).ToModifiable();
    277277
    278       foreach (var transformation in transformations.Reverse()) {
     278      var transformationsStack = new Stack<IDataAnalysisTransformation>(transformations);
     279      while (transformationsStack.Any()) {
     280        var transformation = transformationsStack.Pop();
    279281        var trans = (ITransformation<double>)transformation.Transformation;
    280282
     
    283285        var originalData = trans.InverseApply(transformedData).ToList();
    284286        modifiableDataset.ReplaceVariable(transformation.OriginalVariable, originalData);
     287
     288        bool transformedVariablePending = transformationsStack.Any(x => x.OriginalVariable == transformation.TransformedVariable);
     289        if (removeVirtualVariables && !transformedVariablePending)
     290          modifiableDataset.RemoveVariable(transformation.TransformedVariable);
    285291      }
    286292
Note: See TracChangeset for help on using the changeset viewer.