Ignore:
Timestamp:
05/21/14 11:49:55 (6 years ago)
Author:
pfleck
Message:
  • implemented basic backtransformation without variable weights
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicExpressionTreeBacktransformator.cs

    r10854 r10869  
    3333    }
    3434
    35     public IDataAnalysisModel Backtransform(IDataAnalysisModel model, IEnumerable<ITransformation> transformations) {
     35    public void Backtransform(IDataAnalysisModel model, IEnumerable<ITransformation> transformations) {
    3636      var symbolicModel = (ISymbolicDataAnalysisModel)model;
    3737
     
    3939        ApplyBacktransformation(transformation, symbolicModel.SymbolicExpressionTree);
    4040      }
    41 
    42       return symbolicModel;
    4341    }
    4442
    4543    private void ApplyBacktransformation(ITransformation transformation, ISymbolicExpressionTree symbolicExpressionTree) {
    46       bool modelHasVariable = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsVariableNode(n, transformation.Column));
    47       // TODO
     44      var variableNodes = symbolicExpressionTree.IterateNodesBreadth()
     45        .Where(n => IsVariableNode(n, transformation.Column));
     46
     47      var transformationTree = transformationMapper.GenerateModel(transformation);
     48      foreach (var variableNode in variableNodes) {
     49        SwapTransformationTree(transformationTree, variableNode);
     50      }
     51    }
     52
     53    private void SwapTransformationTree(ISymbolicExpressionTree transformationTree, ISymbolicExpressionTreeNode targetNode) {
     54      var parent = targetNode.Parent;
     55      int index = parent.IndexOfSubtree(targetNode);
     56      parent.RemoveSubtree(index);
     57      parent.InsertSubtree(index, transformationTree.Root.GetSubtree(0));
    4858    }
    4959
Note: See TracChangeset for help on using the changeset viewer.