Changeset 10869


Ignore:
Timestamp:
05/21/14 11:49:55 (5 years ago)
Author:
pfleck
Message:
  • implemented basic backtransformation without variable weights
Location:
branches/DataPreprocessing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs

    r10854 r10869  
    5656      var mapper = new TransformationToSymbolicTreeMapper();
    5757      var transformator = new SymbolicExpressionTreeBacktransformator(mapper);
    58       var model = transformator.Backtransform(Content.Model, Content.ProblemData.Transformations);
    59       MainFormManager.MainForm.ShowContent(model);
     58      transformator.Backtransform(Content.Model, Content.ProblemData.Transformations);
    6059    }
    6160  }
  • 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
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TransformationToSymbolicTreeMapper.cs

    r10866 r10869  
    284284
    285285    private ConstantTreeNode CreateConstantTreeNode(string description, double value) {
    286       return new ConstantTreeNode(new Constant() { Description = description }) { Value = value };
     286      return new ConstantTreeNode(new Constant()) { Value = value };
    287287    }
    288288    private ISymbolicExpressionTreeNode CreateVariableTreeNode(string name, string description) {
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IModelBacktransformator.cs

    r10854 r10869  
    2525namespace HeuristicLab.Problems.DataAnalysis {
    2626  public interface IModelBacktransformator {
    27     IDataAnalysisModel Backtransform(IDataAnalysisModel model, IEnumerable<ITransformation> transformations);
     27    void Backtransform(IDataAnalysisModel model, IEnumerable<ITransformation> transformations);
    2828  }
    2929}
Note: See TracChangeset for help on using the changeset viewer.