Changeset 4464 for branches/DataAnalysis
- Timestamp:
- 09/21/10 14:51:47 (14 years ago)
- Location:
- branches/DataAnalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs
r4463 r4464 105 105 horizon = Content.Horizon; 106 106 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 107 SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone(); 108 SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.CalculateScalingParameters(tree, 107 SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.CalculateScalingParameters(simplifiedExpressionTree, 109 108 Content.ProblemData, interpreter, 110 109 conditionVariableName, rows, 111 110 out beta, out alpha); 112 111 113 quality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Evaluate( tree, Content.ProblemData, interpreter,112 quality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Evaluate(simplifiedExpressionTree, Content.ProblemData, interpreter, 114 113 conditionVariableName, rows, horizon, 115 114 lowerEstimationLimit, upperEstimationLimit, 116 115 beta, alpha); 117 116 118 //double originalQuality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Evaluate(119 120 // .Calculate(121 // Content.Model.Interpreter, new SymbolicExpressionTree(root), Content.LowerEstimationLimit, Content.UpperEstimationLimit,122 // Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,123 // Enumerable.Range(samplesStart, samplesEnd - samplesStart));124 125 117 this.CalculateReplacementNodes(); 126 118 127 this.CalculateNodeImpacts(tree, tree.Root, quality); 119 this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root, quality); 120 // show only interesing part 128 121 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0]); 129 122 this.PaintNodeImpacts(); … … 138 131 SymbolicExpressionTree tree = new SymbolicExpressionTree(root); 139 132 foreach (SymbolicExpressionTreeNode node in this.simplifiedExpressionTree.IterateNodesPrefix()) { 140 if (!(node.Symbol is StartSymbol )) {133 if (!(node.Symbol is StartSymbol || node.Symbol is ProgramRootSymbol)) { 141 134 while (start.SubTrees.Count > 0) start.RemoveSubTree(0); 142 135 start.AddSubTree(node); … … 150 143 private void CalculateNodeImpacts(SymbolicExpressionTree tree, SymbolicExpressionTreeNode currentTreeNode, double originalQuality) { 151 144 foreach (SymbolicExpressionTreeNode childNode in currentTreeNode.SubTrees.ToList()) { 152 if (!(childNode.Symbol is StartSymbol )) {145 if (!(childNode.Symbol is StartSymbol || childNode.Symbol is ProgramRootSymbol)) { 153 146 SwitchNode(currentTreeNode, childNode, replacementNodes[childNode]); 154 147 int samplesStart = Content.ProblemData.TrainingSamplesStart.Value; … … 157 150 double[] beta; 158 151 int horizon = Content.Horizon; 159 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 160 //SymbolicExpressionTree tree = new SymbolicExpressionTree(root); 152 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 161 153 SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.CalculateScalingParameters(tree, 162 154 Content.ProblemData, interpreter, … … 201 193 SymbolicExpressionTreeNode subTree = treeNode.SubTrees[i]; 202 194 if (subTree == visualTreeNode.SymbolicExpressionTreeNode) { 203 treeNode.RemoveSubTree(i);204 if (replacementNodes.ContainsKey(subTree))195 if (replacementNodes.ContainsKey(subTree)) { 196 treeNode.RemoveSubTree(i); 205 197 treeNode.InsertSubTree(i, replacementNodes[subTree]); 206 else if (subTree is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)subTree)) 198 } else if (subTree is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)subTree)) { 199 treeNode.RemoveSubTree(i); 207 200 treeNode.InsertSubTree(i, replacementNodes.Where(v => v.Value == subTree).Single().Key); 208 else if (!(subTree is ConstantTreeNode))209 throw new InvalidOperationException("Could not find replacement value.");201 } 202 // if no replacement value is known do nothing 210 203 } 211 204 } 212 205 } 206 // show only interesting part 213 207 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0]); 214 208 … … 249 243 if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode)) 250 244 this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange; 251 else 252 this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.Black; 245 else { 246 VisualSymbolicExpressionTreeNode visNode = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode); 247 if (visNode != null) 248 visNode.LineColor = Color.Black; 249 } 253 250 } 254 251 } -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r4462 r4464 85 85 int samplesStart = Content.ProblemData.TrainingSamplesStart.Value; 86 86 int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value; 87 SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone();88 87 double originalTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate( 89 Content.Model.Interpreter, tree, Content.LowerEstimationLimit, Content.UpperEstimationLimit,88 Content.Model.Interpreter, simplifiedExpressionTree, Content.LowerEstimationLimit, Content.UpperEstimationLimit, 90 89 Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value, 91 90 Enumerable.Range(samplesStart, samplesEnd - samplesStart)); … … 93 92 this.CalculateReplacementNodes(); 94 93 95 this.CalculateNodeImpacts(tree, tree.Root.SubTrees[0], originalTrainingMeanSquaredError); 94 this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError); 95 // show only interesting part of solution 96 96 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]); 97 97 this.PaintNodeImpacts(); … … 168 168 } 169 169 } 170 171 // show only interesting part of solution 170 172 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]); 171 173 … … 206 208 if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode)) 207 209 this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange; 208 else 209 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 } 210 215 } 211 216 }
Note: See TracChangeset
for help on using the changeset viewer.