Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11146 for stable


Ignore:
Timestamp:
07/08/14 19:30:48 (10 years ago)
Author:
mkommend
Message:

#2156: Merged r10492 into stable.

Location:
stable
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs

    r9456 r11146  
    5959      return model;
    6060    }
    61 
    6261    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
    6362      return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
     
    6867
    6968    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
    70       return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
    71         n => n,
    72         n => calculator.CalculateImpactValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices, Content.TrainingAccuracy)
    73         );
     69      var values = CalculateImpactAndReplacementValues(tree);
     70      return values.ToDictionary(x => x.Key, x => x.Value.Item1);
     71    }
     72
     73    protected override Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree) {
     74      var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>();
     75      foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
     76        double impactValue, replacementValue;
     77        calculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue);
     78        impactAndReplacementValues.Add(node, new Tuple<double, double>(impactValue, replacementValue));
     79      }
     80      return impactAndReplacementValues;
    7481    }
    7582
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r9456 r11146  
    5656
    5757    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
    58       return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
    59         n => n,
    60         n => calculator.CalculateImpactValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices, Content.TrainingRSquared)
    61         );
     58      var values = CalculateImpactAndReplacementValues(tree);
     59      return values.ToDictionary(x => x.Key, x => x.Value.Item1);
     60    }
     61
     62    protected override Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree) {
     63      var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>();
     64      foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
     65        double impactValue, replacementValue;
     66        calculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue);
     67        impactAndReplacementValues.Add(node, new Tuple<double, double>(impactValue, replacementValue));
     68      }
     69      return impactAndReplacementValues;
    6270    }
    6371
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs

    r9462 r11146  
    4949    }
    5050
    51     protected override void UpdateModel(ISymbolicExpressionTree tree) {
    52       var model = new SymbolicTimeSeriesPrognosisModel(tree, Content.Model.Interpreter);
    53       model.Scale(Content.ProblemData);
    54       Content.Model = model;
    55     }
    56 
    57     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
    58       Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
    59       foreach (var componentBranch in tree.Root.GetSubtree(0).Subtrees)
    60         foreach (ISymbolicExpressionTreeNode node in componentBranch.IterateNodesPrefix()) {
    61           replacementValues[node] = CalculateReplacementValue(node, tree);
    62         }
    63       return replacementValues;
    64     }
    65 
    66     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
     51    protected override Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree) {
    6752      var interpreter = Content.Model.Interpreter;
    6853      var rows = Content.ProblemData.TrainingIndices;
     
    7257      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).ToArray();
    7358
    74       Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
     59      var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>();
    7560      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
    7661      OnlineCalculatorError errorState;
     
    9075        // impact < 0 if new solution is better
    9176        // impact > 0 if new solution is worse
    92         impactValues[node] = originalR2 - newR2;
     77        double impact = originalR2 - newR2;
     78        impactAndReplacementValues[node] = new Tuple<double, double>(impact, constantNode.Value);
    9379        SwitchNode(parent, replacementNode, node);
    9480      }
    95       return impactValues;
     81      return impactAndReplacementValues;
     82    }
     83
     84    protected override void UpdateModel(ISymbolicExpressionTree tree) {
     85      var model = new SymbolicTimeSeriesPrognosisModel(tree, Content.Model.Interpreter);
     86      model.Scale(Content.ProblemData);
     87      Content.Model = model;
     88    }
     89
     90    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
     91      var replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
     92      foreach (var componentBranch in tree.Root.GetSubtree(0).Subtrees)
     93        foreach (ISymbolicExpressionTreeNode node in componentBranch.IterateNodesPrefix()) {
     94          replacementValues[node] = CalculateReplacementValue(node, tree);
     95        }
     96      return replacementValues;
     97    }
     98
     99    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
     100      var impactAndReplacementValues = CalculateImpactAndReplacementValues(tree);
     101      return impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); // item1 of the tuple is the impact value
    96102    }
    97103
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r11120 r11146  
    8282      treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0));
    8383
    84       var replacementValues = CalculateReplacementValues(tree);
     84      var impactAndReplacementValues = CalculateImpactAndReplacementValues(tree);
     85      nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
     86      var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
    8587      foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
    8688        foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    8789      }
    88 
    89       nodeImpacts = CalculateImpactValues(tree);
    9090      PaintNodeImpacts();
    9191    }
     
    9393    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree);
    9494    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree);
     95    protected abstract Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree);
    9596    protected abstract void UpdateModel(ISymbolicExpressionTree tree);
    9697
Note: See TracChangeset for help on using the changeset viewer.