- Timestamp:
- 09/23/10 17:12:30 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
-
Property
svn:mergeinfo
set to
/branches/DataAnalysis merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r4068 r4477 83 83 SymbolicSimplifier simplifier = new SymbolicSimplifier(); 84 84 simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree); 85 SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();86 SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();87 root.AddSubTree(start);88 start.AddSubTree(simplifiedExpressionTree.Root);89 85 int samplesStart = Content.ProblemData.TrainingSamplesStart.Value; 90 86 int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value; 91 87 double originalTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate( 92 Content.Model.Interpreter, new SymbolicExpressionTree(root), Content.LowerEstimationLimit, Content.UpperEstimationLimit,88 Content.Model.Interpreter, simplifiedExpressionTree, Content.LowerEstimationLimit, Content.UpperEstimationLimit, 93 89 Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value, 94 90 Enumerable.Range(samplesStart, samplesEnd - samplesStart)); … … 96 92 this.CalculateReplacementNodes(); 97 93 98 this.CalculateNodeImpacts(new SymbolicExpressionTree(root), start, originalTrainingMeanSquaredError); 99 this.treeChart.Tree = simplifiedExpressionTree; 94 this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError); 95 // show only interesting part of solution 96 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]); 100 97 this.PaintNodeImpacts(); 101 98 } … … 110 107 SymbolicExpressionTree tree = new SymbolicExpressionTree(root); 111 108 foreach (SymbolicExpressionTreeNode node in this.simplifiedExpressionTree.IterateNodesPrefix()) { 112 while (start.SubTrees.Count > 0) start.RemoveSubTree(0); 113 start.AddSubTree(node); 114 double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median(); 115 ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue); 116 replacementNodes[node] = constantTreeNode; 109 if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) { 110 while (start.SubTrees.Count > 0) start.RemoveSubTree(0); 111 start.AddSubTree(node); 112 double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median(); 113 ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue); 114 replacementNodes[node] = constantTreeNode; 115 } 117 116 } 118 117 } … … 169 168 } 170 169 } 171 this.treeChart.Tree = simplifiedExpressionTree; 172 173 SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode(); 174 SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode(); 175 root.AddSubTree(start); 176 SymbolicExpressionTree tree = new SymbolicExpressionTree(root); 177 start.AddSubTree(simplifiedExpressionTree.Root); 170 171 // show only interesting part of solution 172 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]); 173 174 SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone(); 178 175 179 176 this.Content.ModelChanged -= new EventHandler(Content_ModelChanged); … … 189 186 double min = impacts.Min(); 190 187 foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) { 191 if (!(treeNode is ConstantTreeNode) ) {188 if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) { 192 189 double impact = this.nodeImpacts[treeNode]; 193 190 double replacementValue = this.replacementNodes[treeNode].Value; … … 211 208 if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode)) 212 209 this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange; 213 else 214 this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.Black; 210 else { 211 VisualSymbolicExpressionTreeNode visNode = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode); 212 if (visNode != null) 213 visNode.LineColor = Color.Black; 214 } 215 215 } 216 216 }
Note: See TracChangeset
for help on using the changeset viewer.