- Timestamp:
- 05/21/14 13:15:53 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicExpressionTreeBacktransformator.cs
r10872 r10874 43 43 private void ApplyBacktransformation(ITransformation transformation, ISymbolicExpressionTree symbolicExpressionTree) { 44 44 var variableNodes = symbolicExpressionTree.IterateNodesBreadth() 45 .Where(n => IsVariableNode(n, transformation.Column)); 45 .OfType<VariableTreeNode>() 46 .Where(n => n.VariableName == transformation.Column); 46 47 47 48 var transformationTree = transformationMapper.GenerateModel(transformation); 48 49 foreach (var variableNode in variableNodes) { 49 SwapTransformation Tree(transformationTree, variableNode);50 SwapTransformationWithVariable(transformationTree, variableNode); 50 51 } 51 52 } 52 53 53 private void SwapTransformation Tree(ISymbolicExpressionTreeNode transformationTreeNode, ISymbolicExpressionTreeNode targetNode) {54 var parent = targetNode.Parent;55 int index = parent.IndexOfSubtree( targetNode);54 private void SwapTransformationWithVariable(ISymbolicExpressionTreeNode transformationTree, VariableTreeNode variableNode) { 55 var parent = variableNode.Parent; 56 int index = parent.IndexOfSubtree(variableNode); 56 57 parent.RemoveSubtree(index); 57 parent.InsertSubtree(index, transformationTreeNode);58 }59 58 60 private bool IsVariableNode(ISymbolicExpressionTreeNode node, string variableName) { 61 var variableNode = node as VariableTreeNode; 62 if (variableNode == null) return false; 63 return variableNode.VariableName == variableName; 59 var multiplicationNode = new SymbolicExpressionTreeNode(new Multiplication()); 60 multiplicationNode.AddSubtree(new ConstantTreeNode(new Constant()) { Value = variableNode.Weight }); 61 multiplicationNode.AddSubtree(transformationTree); 62 63 parent.InsertSubtree(index, multiplicationNode); 64 64 } 65 65 }
Note: See TracChangeset
for help on using the changeset viewer.