Changeset 4475 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3
- Timestamp:
- 09/23/10 13:49:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs
r4464 r4475 95 95 int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value; 96 96 97 double[] alpha, beta;98 97 double quality; 99 98 conditionVariableName = Content.ConditionalEvaluationVariable; 100 99 targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value); 101 100 int nTargetVariables = Content.ProblemData.TargetVariables.CheckedItems.Count(); 102 lowerEstimationLimit = new DoubleArray(Enumerable.Repeat(double.NegativeInfinity, nTargetVariables).ToArray());103 upperEstimationLimit = new DoubleArray(Enumerable.Repeat(double.PositiveInfinity, nTargetVariables).ToArray());104 101 interpreter = Content.Model.Interpreter; 105 102 horizon = Content.Horizon; 106 103 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 107 SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.CalculateScalingParameters(simplifiedExpressionTree, 108 Content.ProblemData, interpreter, 109 conditionVariableName, rows, 110 out beta, out alpha); 111 112 quality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Evaluate(simplifiedExpressionTree, Content.ProblemData, interpreter, 113 conditionVariableName, rows, horizon, 114 lowerEstimationLimit, upperEstimationLimit, 115 beta, alpha); 104 if (!string.IsNullOrEmpty(conditionVariableName)) { 105 rows = (from row in rows 106 where !Content.ProblemData.Dataset[conditionVariableName, row].IsAlmost(0.0) 107 select row).ToList(); 108 } 109 lowerEstimationLimit = new DoubleArray(nTargetVariables); 110 upperEstimationLimit = new DoubleArray(nTargetVariables); 111 for (int i = 0; i < nTargetVariables; i++) { 112 lowerEstimationLimit[i] = Content.GetLowerEstimationLimit(i); 113 upperEstimationLimit[i] = Content.GetUpperEstimationLimit(i); 114 } 115 quality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Calculate(simplifiedExpressionTree, Content.ProblemData, interpreter, 116 rows, horizon, 117 lowerEstimationLimit, upperEstimationLimit); 116 118 117 119 this.CalculateReplacementNodes(); 118 120 119 this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root, quality );121 this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root, quality, rows); 120 122 // show only interesing part 121 123 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0]); … … 134 136 while (start.SubTrees.Count > 0) start.RemoveSubTree(0); 135 137 start.AddSubTree(node); 136 double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, targetVariables, trainingSamples, 1).Select(x => x[0]).Median(); 138 // we only want a scalar replacement value for the single branch that should be evaluated 139 // so assume we only create an estimation for the first target variable 140 double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, targetVariables.Take(1) , trainingSamples, 1).Select(x => x[0]).Median(); 137 141 ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue); 138 142 replacementNodes[node] = constantTreeNode; … … 141 145 } 142 146 143 private void CalculateNodeImpacts(SymbolicExpressionTree tree, SymbolicExpressionTreeNode currentTreeNode, double originalQuality ) {147 private void CalculateNodeImpacts(SymbolicExpressionTree tree, SymbolicExpressionTreeNode currentTreeNode, double originalQuality, IEnumerable<int> rows) { 144 148 foreach (SymbolicExpressionTreeNode childNode in currentTreeNode.SubTrees.ToList()) { 145 149 if (!(childNode.Symbol is StartSymbol || childNode.Symbol is ProgramRootSymbol)) { 146 150 SwitchNode(currentTreeNode, childNode, replacementNodes[childNode]); 147 int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;148 int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;149 double[] alpha;150 double[] beta;151 151 int horizon = Content.Horizon; 152 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 153 SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.CalculateScalingParameters(tree, 154 Content.ProblemData, interpreter, 155 conditionVariableName, rows, 156 out beta, out alpha); 157 158 double newQuality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Evaluate(tree, Content.ProblemData, interpreter, 159 conditionVariableName, rows, horizon, 160 lowerEstimationLimit, upperEstimationLimit, 161 beta, alpha); 152 153 double newQuality = SymbolicTimeSeriesPrognosisScaledNormalizedMseEvaluator.Calculate(tree, Content.ProblemData, interpreter, 154 rows, horizon, 155 lowerEstimationLimit, upperEstimationLimit); 162 156 163 157 nodeImpacts[childNode] = newQuality / originalQuality; 164 158 SwitchNode(currentTreeNode, replacementNodes[childNode], childNode); 165 159 } 166 CalculateNodeImpacts(tree, childNode, originalQuality );160 CalculateNodeImpacts(tree, childNode, originalQuality, rows); 167 161 } 168 162 }
Note: See TracChangeset
for help on using the changeset viewer.