Changeset 2356 for trunk/sources/HeuristicLab.GP.StructureIdentification
- Timestamp:
- 09/15/09 14:01:47 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs
r2351 r2356 30 30 31 31 namespace HeuristicLab.GP.StructureIdentification { 32 public static class DefaultStructureIdentification AlgorithmOperators {32 public static class DefaultStructureIdentificationOperators { 33 33 public static IOperator CreateFunctionLibraryInjector() { 34 34 CombinedOperator op = new CombinedOperator(); … … 37 37 seq.AddSubOperator(new FunctionLibraryInjector()); 38 38 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 39 op.OperatorGraph.AddOperator(seq);40 op.OperatorGraph.InitialOperator = seq;41 return op;42 }43 44 public static IOperator CreateProblemInjector() {45 CombinedOperator op = new CombinedOperator();46 op.Name = "ProblemInjector";47 SequentialProcessor seq = new SequentialProcessor();48 49 seq.AddSubOperator(new ProblemInjector());50 DatasetShuffler shuffler = new DatasetShuffler();51 shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";52 shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";53 seq.AddSubOperator(shuffler);54 39 op.OperatorGraph.AddOperator(seq); 55 40 op.OperatorGraph.InitialOperator = seq; … … 105 90 } 106 91 107 public static IOperator CreatePostProcessingOperator() { 108 CombinedOperator op = new CombinedOperator(); 109 op.Name = "ModelAnalyser"; 92 93 public static IOperator CreatePreparationForPostProcessingOperator() { 110 94 SequentialProcessor seq = new SequentialProcessor(); 111 95 LeftReducer cleanUp = new LeftReducer(); … … 145 129 testEvaluator.GetVariableInfo("Values").ActualName = "TestValues"; 146 130 testEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 147 #endregion148 #region MSE149 SimpleMSEEvaluator trainingMseEvaluator = new SimpleMSEEvaluator();150 trainingMseEvaluator.Name = "TrainingMseEvaluator";151 trainingMseEvaluator.GetVariableInfo("MSE").ActualName = "TrainingMSE";152 trainingMseEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";153 SimpleMSEEvaluator validationMseEvaluator = new SimpleMSEEvaluator();154 validationMseEvaluator.Name = "ValidationMseEvaluator";155 validationMseEvaluator.GetVariableInfo("MSE").ActualName = "ValidationMSE";156 validationMseEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";157 SimpleMSEEvaluator testMseEvaluator = new SimpleMSEEvaluator();158 testMseEvaluator.Name = "TestMseEvaluator";159 testMseEvaluator.GetVariableInfo("MSE").ActualName = "TestMSE";160 testMseEvaluator.GetVariableInfo("Values").ActualName = "TestValues";161 #endregion162 #region MAPE163 SimpleMeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new SimpleMeanAbsolutePercentageErrorEvaluator();164 trainingMapeEvaluator.Name = "TrainingMapeEvaluator";165 trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";166 trainingMapeEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";167 SimpleMeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new SimpleMeanAbsolutePercentageErrorEvaluator();168 validationMapeEvaluator.Name = "ValidationMapeEvaluator";169 validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";170 validationMapeEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";171 SimpleMeanAbsolutePercentageErrorEvaluator testMapeEvaluator = new SimpleMeanAbsolutePercentageErrorEvaluator();172 testMapeEvaluator.Name = "TestMapeEvaluator";173 testMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TestMAPE";174 testMapeEvaluator.GetVariableInfo("Values").ActualName = "TestValues";175 #endregion176 #region MAPRE177 SimpleMeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new SimpleMeanAbsolutePercentageOfRangeErrorEvaluator();178 trainingMapreEvaluator.Name = "TrainingMapreEvaluator";179 trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE";180 trainingMapreEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";181 SimpleMeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new SimpleMeanAbsolutePercentageOfRangeErrorEvaluator();182 validationMapreEvaluator.Name = "ValidationMapreEvaluator";183 validationMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "ValidationMAPRE";184 validationMapreEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";185 SimpleMeanAbsolutePercentageOfRangeErrorEvaluator testMapreEvaluator = new SimpleMeanAbsolutePercentageOfRangeErrorEvaluator();186 testMapreEvaluator.Name = "TestMapreEvaluator";187 testMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TestMAPRE";188 testMapreEvaluator.GetVariableInfo("Values").ActualName = "TestValues";189 #endregion MAPRE190 #region R2191 SimpleR2Evaluator trainingR2Evaluator = new SimpleR2Evaluator();192 trainingR2Evaluator.Name = "TrainingR2Evaluator";193 trainingR2Evaluator.GetVariableInfo("R2").ActualName = "TrainingR2";194 trainingR2Evaluator.GetVariableInfo("Values").ActualName = "TrainingValues";195 SimpleR2Evaluator validationR2Evaluator = new SimpleR2Evaluator();196 validationR2Evaluator.Name = "ValidationR2Evaluator";197 validationR2Evaluator.GetVariableInfo("R2").ActualName = "ValidationR2";198 validationR2Evaluator.GetVariableInfo("Values").ActualName = "ValidationValues";199 SimpleR2Evaluator testR2Evaluator = new SimpleR2Evaluator();200 testR2Evaluator.Name = "TestR2Evaluator";201 testR2Evaluator.GetVariableInfo("R2").ActualName = "TestR2";202 testR2Evaluator.GetVariableInfo("Values").ActualName = "TestValues";203 #endregion204 #region VAF205 SimpleVarianceAccountedForEvaluator trainingVAFEvaluator = new SimpleVarianceAccountedForEvaluator();206 trainingVAFEvaluator.Name = "TrainingVAFEvaluator";207 trainingVAFEvaluator.GetVariableInfo("VAF").ActualName = "TrainingVAF";208 trainingVAFEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";209 SimpleVarianceAccountedForEvaluator validationVAFEvaluator = new SimpleVarianceAccountedForEvaluator();210 validationVAFEvaluator.Name = "ValidationVAFEvaluator";211 validationVAFEvaluator.GetVariableInfo("VAF").ActualName = "ValidationVAF";212 validationVAFEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";213 SimpleVarianceAccountedForEvaluator testVAFEvaluator = new SimpleVarianceAccountedForEvaluator();214 testVAFEvaluator.Name = "TestVAFEvaluator";215 testVAFEvaluator.GetVariableInfo("VAF").ActualName = "TestVAF";216 testVAFEvaluator.GetVariableInfo("Values").ActualName = "TestValues";217 #endregion218 219 131 solutionProc.AddSubOperator(evaluatorInjector); 220 132 solutionProc.AddSubOperator(trainingEvaluator); 221 133 solutionProc.AddSubOperator(validationEvaluator); 222 134 solutionProc.AddSubOperator(testEvaluator); 223 solutionProc.AddSubOperator(trainingMseEvaluator); 224 solutionProc.AddSubOperator(validationMseEvaluator); 225 solutionProc.AddSubOperator(testMseEvaluator); 226 solutionProc.AddSubOperator(trainingMapeEvaluator); 227 solutionProc.AddSubOperator(validationMapeEvaluator); 228 solutionProc.AddSubOperator(testMapeEvaluator); 229 solutionProc.AddSubOperator(trainingMapreEvaluator); 230 solutionProc.AddSubOperator(validationMapreEvaluator); 231 solutionProc.AddSubOperator(testMapreEvaluator); 232 solutionProc.AddSubOperator(trainingR2Evaluator); 233 solutionProc.AddSubOperator(validationR2Evaluator); 234 solutionProc.AddSubOperator(testR2Evaluator); 235 solutionProc.AddSubOperator(trainingVAFEvaluator); 236 solutionProc.AddSubOperator(validationVAFEvaluator); 237 solutionProc.AddSubOperator(testVAFEvaluator); 135 #endregion 238 136 239 137 #region variable impacts … … 244 142 predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 245 143 246 VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator();247 evaluationImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";248 evaluationImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";249 VariableQualityImpactCalculator qualityImpactCalculator = new VariableQualityImpactCalculator();250 qualityImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";251 qualityImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";252 253 144 solutionProc.AddSubOperator(namesExtractor); 254 145 solutionProc.AddSubOperator(predictorBuilder); 255 solutionProc.AddSubOperator(evaluationImpactCalculator);256 solutionProc.AddSubOperator(qualityImpactCalculator);257 146 #endregion 258 147 259 op.OperatorGraph.AddOperator(seq); 260 op.OperatorGraph.InitialOperator = seq; 261 return op; 148 return seq; 262 149 } 263 150 264 public static IAnalyzerModel CreateGPModel(IScope bestModelScope) { 265 IAnalyzerModel model = new AnalyzerModel(); 266 model.Predictor = bestModelScope.GetVariableValue<IPredictor>("Predictor", true); 267 Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 268 model.Dataset = ds; 269 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 270 model.TrainingSamplesStart = bestModelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data; 271 model.TrainingSamplesEnd = bestModelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data; 272 model.ValidationSamplesStart = bestModelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data; 273 model.ValidationSamplesEnd = bestModelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data; 274 model.TestSamplesStart = bestModelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data; 275 model.TestSamplesEnd = bestModelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data; 276 277 model.SetResult("TrainingMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("TrainingMSE", false).Data); 278 model.SetResult("ValidationMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("ValidationMSE", false).Data); 279 model.SetResult("TestMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("TestMSE", false).Data); 280 model.SetResult("TrainingCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data); 281 model.SetResult("ValidationCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data); 282 model.SetResult("TestCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data); 283 model.SetResult("TrainingMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data); 284 model.SetResult("ValidationMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data); 285 model.SetResult("TestMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data); 286 model.SetResult("TrainingMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data); 287 model.SetResult("ValidationMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data); 288 model.SetResult("TestMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data); 289 model.SetResult("TrainingVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data); 290 model.SetResult("ValidationVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data); 291 model.SetResult("TestVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data); 292 293 model.SetMetaData("EvaluatedSolutions", bestModelScope.GetVariableValue<DoubleData>("EvaluatedSolutions", true).Data); 294 IGeneticProgrammingModel gpModel = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("FunctionTree", true); 151 public static void PopulateAnalyzerModel(IScope bestModelScope, IAnalyzerModel model) { 152 model.SetMetaData("EvaluatedSolutions", bestModelScope.GetVariableValue<DoubleData>("EvaluatedSolutions", false).Data); 153 IGeneticProgrammingModel gpModel = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("FunctionTree", false); 295 154 model.SetMetaData("TreeSize", gpModel.Size); 296 155 model.SetMetaData("TreeHeight", gpModel.Height); 297 298 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false);299 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false);300 foreach (ItemList row in evaluationImpacts) {301 string variableName = ((StringData)row[0]).Data;302 double impact = ((DoubleData)row[1]).Data;303 model.SetVariableEvaluationImpact(variableName, impact);304 model.AddInputVariable(variableName);305 }306 foreach (ItemList row in qualityImpacts) {307 string variableName = ((StringData)row[0]).Data;308 double impact = ((DoubleData)row[1]).Data;309 model.SetVariableQualityImpact(variableName, impact);310 model.AddInputVariable(variableName);311 }312 313 return model;314 156 } 315 157 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGP.cs
r2344 r2356 77 77 78 78 protected override IOperator CreateFunctionLibraryInjector() { 79 return DefaultStructureIdentification AlgorithmOperators.CreateFunctionLibraryInjector();79 return DefaultStructureIdentificationOperators.CreateFunctionLibraryInjector(); 80 80 } 81 81 82 82 protected override IOperator CreateProblemInjector() { 83 return Default StructureIdentificationAlgorithmOperators.CreateProblemInjector();83 return DefaultRegressionOperators.CreateProblemInjector(); 84 84 } 85 85 86 86 protected override IOperator CreateInitialPopulationEvaluator() { 87 return DefaultStructureIdentification AlgorithmOperators.CreateInitialPopulationEvaluator();87 return DefaultStructureIdentificationOperators.CreateInitialPopulationEvaluator(); 88 88 } 89 89 90 90 protected override IOperator CreateEvaluationOperator() { 91 return DefaultStructureIdentification AlgorithmOperators.CreateEvaluator();91 return DefaultStructureIdentificationOperators.CreateEvaluator(); 92 92 } 93 93 94 94 95 95 protected override IOperator CreateGenerationStepHook() { 96 return DefaultStructureIdentification AlgorithmOperators.CreateGenerationStepHook();96 return DefaultStructureIdentificationOperators.CreateGenerationStepHook(); 97 97 } 98 98 … … 133 133 134 134 protected override IOperator CreatePostProcessingOperator() { 135 return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator(); 135 CombinedOperator op = new CombinedOperator(); 136 op.Name = "ModelAnalyser"; 137 SequentialProcessor seq = new SequentialProcessor(); 138 seq.AddSubOperator(DefaultStructureIdentificationOperators.CreatePreparationForPostProcessingOperator()); 139 140 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor(); 141 SequentialProcessor solutionProc = new SequentialProcessor(); 142 solutionProc.AddSubOperator(CreateModelAnalyzerOperator()); 143 144 subScopesProc.AddSubOperator(solutionProc); 145 seq.AddSubOperator(subScopesProc); 146 147 op.OperatorGraph.AddOperator(seq); 148 op.OperatorGraph.InitialOperator = seq; 149 return op; 150 } 151 152 protected virtual IOperator CreateModelAnalyzerOperator() { 153 return DefaultRegressionOperators.CreatePostProcessingOperator(); 136 154 } 137 155 … … 148 166 protected virtual IAnalyzerModel CreateGPModel() { 149 167 IScope bestModelScope = Engine.GlobalScope.SubScopes[0]; 150 IAnalyzerModel model = DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope); 151 model.SetMetaData("SelectionPressure", bestModelScope.GetVariableValue<DoubleData>("SelectionPressure", true).Data); 168 var model = new AnalyzerModel(); 169 170 model.SetMetaData("SelectionPressure", bestModelScope.GetVariableValue<DoubleData>("SelectionPressure", false).Data); 171 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 172 DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model); 173 152 174 return model; 153 175 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs
r2344 r2356 78 78 79 79 protected override IOperator CreateFunctionLibraryInjector() { 80 return DefaultStructureIdentification AlgorithmOperators.CreateFunctionLibraryInjector();80 return DefaultStructureIdentificationOperators.CreateFunctionLibraryInjector(); 81 81 } 82 82 83 83 protected override IOperator CreateProblemInjector() { 84 return Default StructureIdentificationAlgorithmOperators.CreateProblemInjector();84 return DefaultRegressionOperators.CreateProblemInjector(); 85 85 } 86 86 87 87 protected override IOperator CreateInitialPopulationEvaluator() { 88 return DefaultStructureIdentification AlgorithmOperators.CreateInitialPopulationEvaluator();88 return DefaultStructureIdentificationOperators.CreateInitialPopulationEvaluator(); 89 89 } 90 90 91 91 protected override IOperator CreateEvaluationOperator() { 92 return DefaultStructureIdentification AlgorithmOperators.CreateEvaluator();92 return DefaultStructureIdentificationOperators.CreateEvaluator(); 93 93 } 94 94 95 95 96 96 protected override IOperator CreateGenerationStepHook() { 97 return DefaultStructureIdentification AlgorithmOperators.CreateGenerationStepHook();97 return DefaultStructureIdentificationOperators.CreateGenerationStepHook(); 98 98 } 99 99 … … 132 132 133 133 protected override IOperator CreatePostProcessingOperator() { 134 return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator(); 134 CombinedOperator op = new CombinedOperator(); 135 op.Name = "ModelAnalyser"; 136 SequentialProcessor seq = new SequentialProcessor(); 137 seq.AddSubOperator(DefaultStructureIdentificationOperators.CreatePreparationForPostProcessingOperator()); 138 139 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor(); 140 SequentialProcessor solutionProc = new SequentialProcessor(); 141 solutionProc.AddSubOperator(CreateModelAnalyzerOperator()); 142 143 subScopesProc.AddSubOperator(solutionProc); 144 seq.AddSubOperator(subScopesProc); 145 146 op.OperatorGraph.AddOperator(seq); 147 op.OperatorGraph.InitialOperator = seq; 148 return op; 149 } 150 151 protected virtual IOperator CreateModelAnalyzerOperator() { 152 return DefaultRegressionOperators.CreatePostProcessingOperator(); 135 153 } 136 154 … … 147 165 protected virtual IAnalyzerModel CreateGPModel() { 148 166 IScope bestModelScope = Engine.GlobalScope.SubScopes[0]; 149 IAnalyzerModel model = DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope); 167 IAnalyzerModel model = new AnalyzerModel(); 168 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 169 DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model); 150 170 return model; 151 171 }
Note: See TracChangeset
for help on using the changeset viewer.