- Timestamp:
- 05/06/10 20:27:08 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj
r3681 r3683 87 87 <Compile Include="Properties\AssemblyInfo.cs" /> 88 88 <Compile Include="Symbolic\Analyzers\BestSymbolicRegressionSolutionAnalyzer.cs" /> 89 <Compile Include="Symbolic\Analyzers\SymbolicRegressionMeanSquaredErrorCalculator.cs" /> 89 90 <Compile Include="Symbolic\Analyzers\ISymbolicRegressionAnalyzer.cs" /> 90 91 <Compile Include="Symbolic\Analyzers\SymbolicRegressionModelQualityAnalyzer.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionModelQualityAnalyzer.cs
r3681 r3683 132 132 133 133 [Storable] 134 private SymbolicRegressionModelQualityCalculator trainingQualityCalculator; 135 [Storable] 136 private SymbolicRegressionModelQualityCalculator testQualityCalculator; 137 [Storable] 134 138 private MinAverageMaxValueAnalyzer minAvgMaxTrainingMseAnalyzer; 135 139 [Storable] … … 161 165 162 166 #region operator initialization 163 // should be extended to calculate MSE, rel. Error and R² on the training (validation) and test set 164 UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor(); 165 SymbolicRegressionModelQualityCalculator trainingQualityCalculator = new SymbolicRegressionModelQualityCalculator(); 166 SymbolicRegressionModelQualityCalculator testQualityCalculator = new SymbolicRegressionModelQualityCalculator(); 167 trainingQualityCalculator = new SymbolicRegressionModelQualityCalculator(); 168 testQualityCalculator = new SymbolicRegressionModelQualityCalculator(); 167 169 minAvgMaxTrainingMseAnalyzer = new MinAverageMaxValueAnalyzer(); 168 170 minAvgMaxTestMseAnalyzer = new MinAverageMaxValueAnalyzer(); … … 182 184 trainingQualityCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 183 185 trainingQualityCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name; 186 trainingQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 184 187 trainingQualityCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name; 185 188 trainingQualityCalculator.AverageRelativeErrorQualityParameter.ActualName = TrainingAverageRelativeErrorQualityParameterName; … … 193 196 testQualityCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 194 197 testQualityCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name; 198 testQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 195 199 testQualityCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name; 196 200 testQualityCalculator.AverageRelativeErrorQualityParameter.ActualName = TestAverageRelativeErrorQualityParameterName; … … 251 255 252 256 #region operator graph 253 OperatorGraph.InitialOperator = subScopesProcessor; 254 subScopesProcessor.Operator = trainingQualityCalculator; 257 OperatorGraph.InitialOperator = trainingQualityCalculator; 255 258 trainingQualityCalculator.Successor = testQualityCalculator; 256 testQualityCalculator.Successor = null; 257 subScopesProcessor.Successor = minAvgMaxTrainingMseAnalyzer; 259 testQualityCalculator.Successor = minAvgMaxTrainingMseAnalyzer; 258 260 minAvgMaxTrainingMseAnalyzer.Successor = minAvgMaxTestMseAnalyzer; 259 261 minAvgMaxTestMseAnalyzer.Successor = minAvgMaxTrainingRSquaredAnalyzer; … … 282 284 283 285 private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) { 286 trainingQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 287 testQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 284 288 minAvgMaxTrainingMseAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth; 285 289 minAvgMaxTrainingRelErrorAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionModelQualityCalculator.cs
r3681 r3683 57 57 58 58 #region parameter properties 59 public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { 60 get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } 61 } 59 62 public IValueLookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { 60 63 get { return (IValueLookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; } 61 }62 public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {63 get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }64 64 } 65 65 public IValueLookupParameter<DataAnalysisProblemData> ProblemDataParameter { … … 92 92 : base() { 93 93 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic expression tree.")); 94 Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree to analyze."));94 Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree to analyze.")); 95 95 Parameters.Add(new ValueLookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data containing the input varaibles for the symbolic regression problem.")); 96 96 Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The first index of the data set partition on which the model quality values should be calculated.")); … … 122 122 simpleR2Evalator.ValuesParameter.ActualName = ValuesParameterName; 123 123 simpleR2Evalator.RSquaredParameter.ActualName = RSquaredQualityParameter.Name; 124 124 125 125 simpleMseEvaluator.ValuesParameter.ActualName = ValuesParameterName; 126 126 simpleMseEvaluator.MeanSquaredErrorParameter.ActualName = MeanSquaredErrorQualityParameter.Name; 127 127 128 128 simpleRelErrorEvaluator.ValuesParameter.ActualName = ValuesParameterName; 129 129 simpleRelErrorEvaluator.AverageRelativeErrorParameter.ActualName = AverageRelativeErrorQualityParameter.Name; … … 143 143 144 144 } 145 146 // need to create custom operations for each solution scope (this has to be adapted on basis of the depth value of SymbolicExpressionTreeParameter) 147 public override IOperation Apply() { 148 var scopes = GetScopesOnLevel(ExecutionContext.Scope, SymbolicExpressionTreeParameter.Depth); 149 OperationCollection operations = new OperationCollection(); 150 foreach (IScope treeScopes in scopes) { 151 operations.Add(ExecutionContext.CreateChildOperation(OperatorGraph.InitialOperator, treeScopes)); 152 } 153 if (Successor != null) operations.Add(ExecutionContext.CreateOperation(Successor)); 154 return operations; 155 } 156 157 private IEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) { 158 if (d == 0) yield return scope; 159 else { 160 foreach (IScope subScope in scope.SubScopes) { 161 foreach (IScope scopesOfSubScope in GetScopesOnLevel(subScope, d - 1)) { 162 yield return scopesOfSubScope; 163 } 164 } 165 } 166 } 145 167 } 146 168 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionSolutionLinearScaler.cs
r3651 r3683 47 47 private const string BetaParameterName = "Beta"; 48 48 49 public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {50 get { return ( ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }49 public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { 50 get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } 51 51 } 52 public ILookupParameter<SymbolicExpressionTree> ScaledSymbolicExpressionTreeParameter {53 get { return ( ILookupParameter<SymbolicExpressionTree>)Parameters[ScaledSymbolicExpressionTreeParameterName]; }52 public ScopeTreeLookupParameter<SymbolicExpressionTree> ScaledSymbolicExpressionTreeParameter { 53 get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[ScaledSymbolicExpressionTreeParameterName]; } 54 54 } 55 public ILookupParameter<DoubleValue> AlphaParameter {56 get { return ( ILookupParameter<DoubleValue>)Parameters[AlphaParameterName]; }55 public ScopeTreeLookupParameter<DoubleValue> AlphaParameter { 56 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[AlphaParameterName]; } 57 57 } 58 public ILookupParameter<DoubleValue> BetaParameter {59 get { return ( ILookupParameter<DoubleValue>)Parameters[BetaParameterName]; }58 public ScopeTreeLookupParameter<DoubleValue> BetaParameter { 59 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[BetaParameterName]; } 60 60 } 61 61 62 62 public SymbolicRegressionSolutionLinearScaler() 63 63 : base() { 64 Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to transform."));65 Parameters.Add(new LookupParameter<SymbolicExpressionTree>(ScaledSymbolicExpressionTreeParameterName, "The resulting symbolic expression trees after transformation."));66 Parameters.Add(new LookupParameter<DoubleValue>(AlphaParameterName, "Alpha parameter for linear transformation."));67 Parameters.Add(new LookupParameter<DoubleValue>(BetaParameterName, "Beta parameter for linear transformation."));64 Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to transform.")); 65 Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(ScaledSymbolicExpressionTreeParameterName, "The resulting symbolic expression trees after transformation.")); 66 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(AlphaParameterName, "Alpha parameter for linear transformation.")); 67 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(BetaParameterName, "Beta parameter for linear transformation.")); 68 68 } 69 69 70 70 public override IOperation Apply() { 71 SymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue; 72 double alpha = AlphaParameter.ActualValue.Value; 73 double beta = BetaParameter.ActualValue.Value; 71 ItemArray<SymbolicExpressionTree> trees = SymbolicExpressionTreeParameter.ActualValue; 72 ItemArray<DoubleValue> alphas = AlphaParameter.ActualValue; 73 ItemArray<DoubleValue> betas = BetaParameter.ActualValue; 74 ItemArray<SymbolicExpressionTree> scaledTrees = new ItemArray<SymbolicExpressionTree>(trees.Length); 75 for (int i = 0; i < trees.Length; i++) { 76 var mainBranch = trees[i].Root.SubTrees[0].SubTrees[0]; 77 var scaledMainBranch = MakeSum(MakeProduct(betas[i].Value, mainBranch), alphas[i].Value); 74 78 75 var mainBranch = tree.Root.SubTrees[0].SubTrees[0]; 76 var scaledMainBranch = MakeSum(MakeProduct(beta, mainBranch), alpha); 77 78 // remove the main branch before cloning to prevent cloning of sub-trees 79 tree.Root.SubTrees[0].RemoveSubTree(0); 80 var scaledTree = (SymbolicExpressionTree)tree.Clone(); 81 // insert main branch into the original tree again 82 tree.Root.SubTrees[0].InsertSubTree(0, mainBranch); 83 // insert the scaled main branch into the cloned tree 84 scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch); 85 ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTree; 79 // remove the main branch before cloning to prevent cloning of sub-trees 80 trees[i].Root.SubTrees[0].RemoveSubTree(0); 81 var scaledTree = (SymbolicExpressionTree)trees[i].Clone(); 82 // insert main branch into the original tree again 83 trees[i].Root.SubTrees[0].InsertSubTree(0, mainBranch); 84 // insert the scaled main branch into the cloned tree 85 scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch); 86 scaledTrees[i] = scaledTree; 87 } 88 ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTrees; 86 89 return base.Apply(); 87 90 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/ValidationBestScaledSymbolicRegressionSolutionAnalyzer.cs
r3681 r3683 95 95 [Storable] 96 96 private BestSymbolicRegressionSolutionAnalyzer bestSolutionAnalyzer; 97 [Storable] 98 private SymbolicRegressionSolutionLinearScaler linearScaler; 99 [Storable] 100 private SymbolicRegressionMeanSquaredErrorCalculator validationMseCalculator; 97 101 98 102 public ValidationBestScaledSymbolicRegressionSolutionAnalyzer() … … 110 114 111 115 #region operator initialization 112 UniformSubScopesProcessor subScopesProc = new UniformSubScopesProcessor(); 113 SymbolicRegressionSolutionLinearScaler linearScaler = new SymbolicRegressionSolutionLinearScaler(); 114 SymbolicRegressionMeanSquaredErrorEvaluator validationMseEvaluator = new SymbolicRegressionMeanSquaredErrorEvaluator(); 116 linearScaler = new SymbolicRegressionSolutionLinearScaler(); 117 validationMseCalculator = new SymbolicRegressionMeanSquaredErrorCalculator(); 115 118 bestSolutionAnalyzer = new BestSymbolicRegressionSolutionAnalyzer(); 116 119 validationQualityMemorizer = new BestQualityMemorizer(); … … 122 125 #region parameter wiring 123 126 linearScaler.AlphaParameter.ActualName = AlphaParameterName; 127 linearScaler.AlphaParameter.Depth = SymbolicExpressionTreeParameter.Depth; 124 128 linearScaler.BetaParameter.ActualName = BetaParameterName; 129 linearScaler.BetaParameter.Depth = SymbolicExpressionTreeParameter.Depth; 125 130 linearScaler.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name; 131 linearScaler.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 126 132 linearScaler.ScaledSymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName; 127 128 validationMseEvaluator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name; 129 validationMseEvaluator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name; 130 validationMseEvaluator.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName; 131 validationMseEvaluator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 132 validationMseEvaluator.QualityParameter.ActualName = QualityParameterName; 133 validationMseEvaluator.RegressionProblemDataParameter.ActualName = ProblemDataParameter.Name; 134 validationMseEvaluator.SamplesStartParameter.ActualName = SamplesStartParameter.Name; 135 validationMseEvaluator.SamplesEndParameter.ActualName = SamplesEndParameter.Name; 133 linearScaler.ScaledSymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 134 135 validationMseCalculator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name; 136 validationMseCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name; 137 validationMseCalculator.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName; 138 validationMseCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 139 validationMseCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 140 validationMseCalculator.QualityParameter.ActualName = QualityParameterName; 141 validationMseCalculator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 142 validationMseCalculator.SamplesStartParameter.ActualName = SamplesStartParameter.Name; 143 validationMseCalculator.SamplesEndParameter.ActualName = SamplesEndParameter.Name; 136 144 137 145 bestSolutionAnalyzer.BestSolutionParameter.ActualName = BestSolutionParameter.Name; … … 167 175 168 176 #region operator graph 169 OperatorGraph.InitialOperator = subScopesProc; 170 subScopesProc.Operator = linearScaler; 171 linearScaler.Successor = validationMseEvaluator; 172 validationMseEvaluator.Successor = null; 173 subScopesProc.Successor = bestSolutionAnalyzer; 177 OperatorGraph.InitialOperator = linearScaler; 178 linearScaler.Successor = validationMseCalculator; 179 validationMseCalculator.Successor = bestSolutionAnalyzer; 174 180 bestSolutionAnalyzer.Successor = bestAvgWorstValidationQualityCalculator; 175 181 bestAvgWorstValidationQualityCalculator.Successor = validationQualityMemorizer; … … 197 203 198 204 private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) { 205 validationMseCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 199 206 validationQualityMemorizer.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth; 200 207 bestSolutionAnalyzer.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 208 bestSolutionAnalyzer.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth; 209 linearScaler.AlphaParameter.Depth = SymbolicExpressionTreeParameter.Depth; 210 linearScaler.BetaParameter.Depth = SymbolicExpressionTreeParameter.Depth; 211 linearScaler.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 212 linearScaler.ScaledSymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth; 201 213 } 202 214 }
Note: See TracChangeset
for help on using the changeset viewer.