Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10878


Ignore:
Timestamp:
05/21/14 14:16:54 (8 years ago)
Author:
pfleck
Message:
  • Fixed bug in backtransformation when model contains same variable multiple times.
Location:
branches/DataPreprocessing
Files:
3 edited

Legend:

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

    r10854 r10878  
    8989      this.transformModelButton.Location = new System.Drawing.Point(84, 3);
    9090      this.transformModelButton.Name = "transformModelButton";
    91       this.transformModelButton.Size = new System.Drawing.Size(100, 23);
     91      this.transformModelButton.Size = new System.Drawing.Size(125, 23);
    9292      this.transformModelButton.TabIndex = 8;
    9393      this.transformModelButton.Text = "Backtransform Model";
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicExpressionTreeBacktransformator.cs

    r10874 r10878  
    2222using System.Collections.Generic;
    2323using System.Linq;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2526using HeuristicLab.Problems.DataAnalysis.Transformations;
     
    4647        .Where(n => n.VariableName == transformation.Column);
    4748
    48       var transformationTree = transformationMapper.GenerateModel(transformation);
    4949      foreach (var variableNode in variableNodes) {
     50        // generate new subtrees because same subtree cannot be added more than once
     51        var transformationTree = transformationMapper.GenerateModel(transformation);
    5052        SwapTransformationWithVariable(transformationTree, variableNode);
    5153      }
     
    5759      parent.RemoveSubtree(index);
    5860
     61      if (!variableNode.Weight.IsAlmost(1.0)) {
     62        transformationTree = CreateNodeFromWeight(transformationTree, variableNode);
     63      }
     64
     65      parent.InsertSubtree(index, transformationTree);
     66    }
     67
     68    private ISymbolicExpressionTreeNode CreateNodeFromWeight(ISymbolicExpressionTreeNode transformationTree, VariableTreeNode variableNode) {
    5969      var multiplicationNode = new SymbolicExpressionTreeNode(new Multiplication());
    6070      multiplicationNode.AddSubtree(new ConstantTreeNode(new Constant()) { Value = variableNode.Weight });
    6171      multiplicationNode.AddSubtree(transformationTree);
    62 
    63       parent.InsertSubtree(index, multiplicationNode);
     72      transformationTree = multiplicationNode;
     73      return transformationTree;
    6474    }
    6575  }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TransformationToSymbolicTreeMapper.cs

    r10872 r10878  
    273273    }
    274274
    275     private ISymbolicExpressionTreeNode CreateVariableTreeNode(string name, string description) {
    276       return new Variable(name, description).CreateTreeNode();
     275    private VariableTreeNode CreateVariableTreeNode(string name, string description) {
     276      return new VariableTreeNode(new Variable(name, description)) { VariableName = name, Weight = 1.0 };
    277277    }
    278278
Note: See TracChangeset for help on using the changeset viewer.