- Timestamp:
- 02/20/14 20:37:55 (11 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs
r9456 r10492 59 59 return model; 60 60 } 61 62 61 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 63 62 return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary( … … 68 67 69 68 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; 74 81 } 75 82 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r9456 r10492 56 56 57 57 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; 62 70 } 63 71 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs
r9462 r10492 49 49 } 50 50 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) { 67 52 var interpreter = Content.Model.Interpreter; 68 53 var rows = Content.ProblemData.TrainingIndices; … … 72 57 var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).ToArray(); 73 58 74 Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();59 var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>(); 75 60 List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList(); 76 61 OnlineCalculatorError errorState; … … 90 75 // impact < 0 if new solution is better 91 76 // 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); 93 79 SwitchNode(parent, replacementNode, node); 94 80 } 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 96 102 } 97 103 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r9478 r10492 75 75 treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 76 76 77 var replacementValues = CalculateReplacementValues(tree); 77 var impactAndReplacementValues = CalculateImpactAndReplacementValues(tree); 78 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 79 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 78 80 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 79 81 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 80 82 } 81 82 nodeImpacts = CalculateImpactValues(tree);83 83 PaintNodeImpacts(); 84 84 } … … 86 86 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree); 87 87 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree); 88 protected abstract Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree); 88 89 protected abstract void UpdateModel(ISymbolicExpressionTree tree); 89 90
Note: See TracChangeset
for help on using the changeset viewer.