Changeset 2356
- Timestamp:
- 09/15/09 14:01:47 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 15 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj
r2351 r2356 81 81 <ItemGroup> 82 82 <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" /> 83 <Compile Include="DefaultClassificationAlgorithmOperators.cs" />84 83 <Compile Include="GPClassificationEvaluatorBase.cs" /> 85 84 <Compile Include="CrossValidation.cs" /> -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs
r2344 r2356 23 23 using HeuristicLab.Modeling; 24 24 using HeuristicLab.Operators; 25 using HeuristicLab.Data; 25 26 26 27 namespace HeuristicLab.GP.StructureIdentification.Classification { 27 28 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm { 28 29 29 protected override IOperator CreateProblemInjector() { 30 return DefaultClassificationAlgorithmOperators.CreateProblemInjector(); 30 public override string Name { 31 get { 32 return base.Name + " - Classification"; 33 } 31 34 } 32 35 33 protected override IOperator CreateP ostProcessingOperator() {34 return DefaultClassification AlgorithmOperators.CreatePostProcessingOperator();36 protected override IOperator CreateProblemInjector() { 37 return DefaultClassificationOperators.CreateProblemInjector(); 35 38 } 36 39 37 protected override IAnalyzerModel CreateGPModel() { 38 IAnalyzerModel model = base.CreateGPModel(); 39 DefaultClassificationAlgorithmOperators.SetModelData(model, Engine.GlobalScope.SubScopes[0]); 40 protected override IOperator CreateModelAnalyzerOperator() { 41 return DefaultClassificationOperators.CreatePostProcessingOperator(); 42 } 43 44 protected virtual IAnalyzerModel CreateGPModel() { 45 IScope bestModelScope = Engine.GlobalScope.SubScopes[0]; 46 var model = new AnalyzerModel(); 47 48 model.SetMetaData("SelectionPressure", bestModelScope.GetVariableValue<DoubleData>("SelectionPressure", false).Data); 49 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 50 DefaultClassificationOperators.PopulateAnalyzerModel(bestModelScope, model); 51 40 52 return model; 41 53 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs
r2344 r2356 27 27 namespace HeuristicLab.GP.StructureIdentification.Classification { 28 28 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm { 29 public override string Name { 30 get { 31 return base.Name + " - Classification"; 32 } 33 } 34 29 35 protected override IOperator CreateProblemInjector() { 30 return DefaultClassification AlgorithmOperators.CreateProblemInjector();36 return DefaultClassificationOperators.CreateProblemInjector(); 31 37 } 32 33 protected override IOperator Create PostProcessingOperator() {34 return DefaultClassification AlgorithmOperators.CreatePostProcessingOperator();38 39 protected override IOperator CreateModelAnalyzerOperator() { 40 return DefaultClassificationOperators.CreatePostProcessingOperator(); 35 41 } 36 42 37 43 protected override IAnalyzerModel CreateGPModel() { 38 IAnalyzerModel model = base.CreateGPModel(); 39 DefaultClassificationAlgorithmOperators.SetModelData(model, Engine.GlobalScope.SubScopes[0]); 44 var model = new AnalyzerModel(); 45 var bestModelScope = Engine.GlobalScope.SubScopes[0]; 46 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 47 DefaultClassificationOperators.PopulateAnalyzerModel(bestModelScope, model); 40 48 return model; 41 49 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj
r2352 r2356 83 83 <ItemGroup> 84 84 <Compile Include="AveragePercentageChangeEvaluator.cs" /> 85 <Compile Include="DefaultTimeSeriesOperators.cs" />86 85 <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" /> 87 86 <Compile Include="OffspringSelectionGP.cs" /> -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs
r2344 r2356 29 29 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 30 30 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm { 31 public override string Name { 32 get { 33 return base.Name + " - time series prognosis"; 34 } 35 } 31 36 32 37 public int MinTimeOffset { … … 50 55 51 56 protected override IOperator CreateFunctionLibraryInjector() { 52 return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector(); 53 } 54 55 protected override IOperator CreatePostProcessingOperator() { 56 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 57 CombinedOperator op = new CombinedOperator(); 58 op.Name = "FunctionLibraryInjector"; 59 SequentialProcessor seq = new SequentialProcessor(); 60 FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector(); 61 funLibInjector.GetVariable("Differentials").Value = new BoolData(true); 62 seq.AddSubOperator(funLibInjector); 63 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 64 op.OperatorGraph.AddOperator(seq); 65 op.OperatorGraph.InitialOperator = seq; 66 return op; 57 67 } 58 68 … … 65 75 } 66 76 77 protected override IOperator CreateModelAnalyzerOperator() { 78 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 79 } 80 67 81 protected override IAnalyzerModel CreateGPModel() { 68 IAnalyzerModel model = base.CreateGPModel(); 69 DefaultTimeSeriesOperators.SetModelData(model, Engine.GlobalScope.SubScopes[0]); 82 var model = new AnalyzerModel(); 83 var bestModelScope = Engine.GlobalScope.SubScopes[0]; 84 model.SetMetaData("SelectionPressure", bestModelScope.GetVariableValue<DoubleData>("SelectionPressure", false).Data); 85 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 86 DefaultTimeSeriesOperators.PopulateAnalyzerModel(bestModelScope, model); 70 87 return model; 71 88 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs
r2344 r2356 29 29 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 30 30 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm { 31 public override string Name { 32 get { 33 return base.Name + " - time series prognosis"; 34 } 35 } 36 31 37 public int MinTimeOffset { 32 38 get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; } … … 49 55 50 56 protected override IOperator CreateFunctionLibraryInjector() { 51 return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector(); 57 CombinedOperator op = new CombinedOperator(); 58 op.Name = "FunctionLibraryInjector"; 59 SequentialProcessor seq = new SequentialProcessor(); 60 FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector(); 61 funLibInjector.GetVariable("Differentials").Value = new BoolData(true); 62 seq.AddSubOperator(funLibInjector); 63 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 64 op.OperatorGraph.AddOperator(seq); 65 op.OperatorGraph.InitialOperator = seq; 66 return op; 52 67 } 53 68 54 protected override IOperator Create PostProcessingOperator() {69 protected override IOperator CreateModelAnalyzerOperator() { 55 70 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 56 71 } … … 65 80 66 81 protected override IAnalyzerModel CreateGPModel() { 67 IAnalyzerModel model = base.CreateGPModel(); 68 DefaultTimeSeriesOperators.SetModelData(model, Engine.GlobalScope.SubScopes[0]); 82 var model = new AnalyzerModel(); 83 var bestModelScope = Engine.GlobalScope.SubScopes[0]; 84 DefaultStructureIdentificationOperators.PopulateAnalyzerModel(bestModelScope, model); 85 DefaultTimeSeriesOperators.PopulateAnalyzerModel(bestModelScope, model); 69 86 return model; 70 87 } -
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 } -
trunk/sources/HeuristicLab.LinearRegression/3.2/LinearClassification.cs
r2353 r2356 38 38 39 39 namespace HeuristicLab.LinearRegression { 40 public class LinearClassification : LinearRegression {40 public class LinearClassification : LinearRegression, IClassificationAlgorithm { 41 41 42 42 public override string Name { get { return "LinearClassification"; } } … … 46 46 } 47 47 48 protected override IOperator CreateModelAnalyser() { 49 return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator(); 48 protected override IOperator CreateProblemInjector() { 49 return DefaultClassificationOperators.CreateProblemInjector(); 50 } 51 52 protected override IOperator CreateModelAnalyzerOperator() { 53 return DefaultClassificationOperators.CreatePostProcessingOperator(); 50 54 } 51 55 52 56 protected internal virtual IAnalyzerModel CreateLRModel(IScope bestModelScope) { 53 IAnalyzerModel model = base.CreateLRModel(bestModelScope);54 DefaultClassification AlgorithmOperators.SetModelData(model, bestModelScope);57 var model = new AnalyzerModel(); 58 DefaultClassificationOperators.PopulateAnalyzerModel(bestModelScope, model); 55 59 return model; 56 60 } -
trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs
r2353 r2356 87 87 CombinedOperator algo = new CombinedOperator(); 88 88 SequentialProcessor seq = new SequentialProcessor(); 89 algo.Name = "LinearRegression"; 90 seq.Name = "LinearRegression"; 91 92 var randomInjector = new RandomInjector(); 93 randomInjector.Name = "Random Injector"; 89 algo.Name = Name; 90 seq.Name = Name; 91 94 92 IOperator globalInjector = CreateGlobalInjector(); 95 ProblemInjector problemInjector = new ProblemInjector(); 96 problemInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true; 97 problemInjector.AddVariable(new HeuristicLab.Core.Variable("MaxNumberOfTrainingSamples", new IntData(5000))); 98 99 HL2TreeEvaluatorInjector treeEvaluatorInjector = new HL2TreeEvaluatorInjector(); 100 101 IOperator shuffler = new DatasetShuffler(); 102 shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart"; 103 shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd"; 93 94 HL3TreeEvaluatorInjector treeEvaluatorInjector = new HL3TreeEvaluatorInjector(); 95 104 96 105 97 LinearRegressionOperator lrOperator = new LinearRegressionOperator(); … … 107 99 lrOperator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd"; 108 100 109 seq.AddSubOperator(randomInjector);110 seq.AddSubOperator(problemInjector);111 101 seq.AddSubOperator(globalInjector); 102 seq.AddSubOperator(new RandomInjector()); 103 seq.AddSubOperator(CreateProblemInjector()); 112 104 seq.AddSubOperator(treeEvaluatorInjector); 113 seq.AddSubOperator(shuffler);114 105 seq.AddSubOperator(lrOperator); 115 seq.AddSubOperator(Create ModelAnalyser());106 seq.AddSubOperator(CreatePostProcessingOperator()); 116 107 117 108 algo.OperatorGraph.InitialOperator = seq; … … 119 110 120 111 return algo; 112 } 113 114 protected virtual IOperator CreateProblemInjector() { 115 return DefaultRegressionOperators.CreateProblemInjector(); 121 116 } 122 117 … … 129 124 } 130 125 131 protected virtual IOperator Create ModelAnalyser() {126 protected virtual IOperator CreatePostProcessingOperator() { 132 127 CombinedOperator op = new CombinedOperator(); 133 op.AddVariableInfo(new VariableInfo("FunctionTree", "The model to analyze", typeof(IGeneticProgrammingModel), VariableKind.In));134 128 op.Name = "Model Analyzer"; 135 op.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 136 137 IOperator maOp = DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator(); 138 op.OperatorGraph.AddOperator(maOp); 139 op.OperatorGraph.InitialOperator = maOp; 129 130 SequentialProcessor seq = new SequentialProcessor(); 131 HL3TreeEvaluatorInjector evaluatorInjector = new HL3TreeEvaluatorInjector(); 132 evaluatorInjector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000.0))); 133 evaluatorInjector.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 134 135 #region simple evaluators 136 SimpleEvaluator trainingEvaluator = new SimpleEvaluator(); 137 trainingEvaluator.Name = "TrainingEvaluator"; 138 trainingEvaluator.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 139 trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 140 trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 141 trainingEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 142 trainingEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 143 SimpleEvaluator validationEvaluator = new SimpleEvaluator(); 144 validationEvaluator.Name = "ValidationEvaluator"; 145 validationEvaluator.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 146 validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 147 validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 148 validationEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues"; 149 validationEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 150 SimpleEvaluator testEvaluator = new SimpleEvaluator(); 151 testEvaluator.Name = "TestEvaluator"; 152 testEvaluator.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 153 testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 154 testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 155 testEvaluator.GetVariableInfo("Values").ActualName = "TestValues"; 156 testEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 157 seq.AddSubOperator(evaluatorInjector); 158 seq.AddSubOperator(trainingEvaluator); 159 seq.AddSubOperator(validationEvaluator); 160 seq.AddSubOperator(testEvaluator); 161 #endregion 162 163 #region variable impacts 164 // calculate and set variable impacts 165 VariableNamesExtractor namesExtractor = new VariableNamesExtractor(); 166 namesExtractor.GetVariableInfo("VariableNames").ActualName = "InputVariableNames"; 167 namesExtractor.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 168 169 PredictorBuilder predictorBuilder = new PredictorBuilder(); 170 predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 171 predictorBuilder.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel"; 172 173 seq.AddSubOperator(namesExtractor); 174 seq.AddSubOperator(predictorBuilder); 175 #endregion 176 177 seq.AddSubOperator(CreateModelAnalyzerOperator()); 178 179 op.OperatorGraph.AddOperator(seq); 180 op.OperatorGraph.InitialOperator = seq; 140 181 return op; 141 182 } 142 183 184 protected virtual IOperator CreateModelAnalyzerOperator() { 185 return DefaultRegressionOperators.CreatePostProcessingOperator(); 186 } 187 143 188 protected virtual IAnalyzerModel CreateLRModel(IScope bestModelScope) { 144 return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope); 189 var model = new AnalyzerModel(); 190 DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model); 191 return model; 145 192 } 146 193 -
trunk/sources/HeuristicLab.Modeling/3.2/DefaultClassificationOperators.cs
r2354 r2356 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.DataAnalysis; 24 using HeuristicLab.GP.Interfaces;25 24 using HeuristicLab.Operators; 26 25 using HeuristicLab.Modeling; 27 26 using HeuristicLab.Data; 28 27 29 namespace HeuristicLab. GP.StructureIdentification.Classification{30 public static class DefaultClassification AlgorithmOperators {28 namespace HeuristicLab.Modeling { 29 public static class DefaultClassificationOperators { 31 30 public static IOperator CreatePostProcessingOperator() { 31 CombinedOperator op = new CombinedOperator(); 32 op.Name = "Classification model analyzer"; 33 32 34 SequentialProcessor seq = new SequentialProcessor(); 33 seq.AddSubOperator(Default StructureIdentificationAlgorithmOperators.CreatePostProcessingOperator());35 seq.AddSubOperator(DefaultRegressionOperators.CreatePostProcessingOperator()); 34 36 35 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();36 SequentialProcessor individualProc = new SequentialProcessor();37 subScopesProc.AddSubOperator(individualProc);38 seq.AddSubOperator(subScopesProc);39 37 SimpleAccuracyEvaluator trainingAccuracy = new SimpleAccuracyEvaluator(); 40 38 trainingAccuracy.Name = "TrainingAccuracyEvaluator"; … … 52 50 testAccuracy.GetVariableInfo("Values").ActualName = "TestValues"; 53 51 54 individualProc.AddSubOperator(trainingAccuracy); 55 individualProc.AddSubOperator(validationAccuracy); 56 individualProc.AddSubOperator(testAccuracy); 57 return seq; 52 SimpleConfusionMatrixEvaluator trainingConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 53 trainingConfusionMatrixEvaluator.Name = "TrainingConfusionMatrixEvaluator"; 54 trainingConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 55 trainingConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "TrainingConfusionMatrix"; 56 SimpleConfusionMatrixEvaluator validationConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 57 validationConfusionMatrixEvaluator.Name = "ValidationConfusionMatrixEvaluator"; 58 validationConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues"; 59 validationConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "ValidationConfusionMatrix"; 60 SimpleConfusionMatrixEvaluator testConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 61 testConfusionMatrixEvaluator.Name = "TestConfusionMatrixEvaluator"; 62 testConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "TestValues"; 63 testConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "TestConfusionMatrix"; 64 65 seq.AddSubOperator(trainingAccuracy); 66 seq.AddSubOperator(validationAccuracy); 67 seq.AddSubOperator(testAccuracy); 68 seq.AddSubOperator(trainingConfusionMatrixEvaluator); 69 seq.AddSubOperator(validationConfusionMatrixEvaluator); 70 seq.AddSubOperator(testConfusionMatrixEvaluator); 71 72 op.OperatorGraph.AddOperator(seq); 73 op.OperatorGraph.InitialOperator = seq; 74 75 return op; 58 76 } 59 77 60 78 public static IOperator CreateProblemInjector() { 61 CombinedOperator op = new CombinedOperator(); 62 op.Name = "ProblemInjector"; 63 SequentialProcessor seq = new SequentialProcessor(); 64 seq.AddSubOperator(new ProblemInjector()); 65 seq.AddSubOperator(new TargetClassesCalculator()); 66 op.OperatorGraph.AddOperator(seq); 67 op.OperatorGraph.InitialOperator = seq; 68 return op; 79 return DefaultRegressionOperators.CreateProblemInjector(); 69 80 } 70 81 71 public static void SetModelData(IAnalyzerModel model, IScope scope) { 72 model.SetResult("TrainingAccuracy", scope.GetVariableValue<DoubleData>("TrainingAccuracy", true).Data); 73 model.SetResult("ValidationAccuracy", scope.GetVariableValue<DoubleData>("ValidationAccuracy", true).Data); 74 model.SetResult("TestAccuracy", scope.GetVariableValue<DoubleData>("TestAccuracy", true).Data); 82 public static IAnalyzerModel PopulateAnalyzerModel(IScope modelScope, IAnalyzerModel model) { 83 DefaultRegressionOperators.PopulateAnalyzerModel(modelScope, model); 84 model.SetResult("TrainingAccuracy", modelScope.GetVariableValue<DoubleData>("TrainingAccuracy", false).Data); 85 model.SetResult("ValidationAccuracy", modelScope.GetVariableValue<DoubleData>("ValidationAccuracy", false).Data); 86 model.SetResult("TestAccuracy", modelScope.GetVariableValue<DoubleData>("TestAccuracy", false).Data); 87 return model; 75 88 } 76 89 } -
trunk/sources/HeuristicLab.Modeling/3.2/DefaultRegressionOperators.cs
r2354 r2356 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.DataAnalysis; 24 using HeuristicLab.GP.Interfaces;25 24 using HeuristicLab.Operators; 26 25 using HeuristicLab.Modeling; 27 using HeuristicLab.Logging;28 using HeuristicLab.Selection;29 26 using HeuristicLab.Data; 30 27 31 namespace HeuristicLab.GP.StructureIdentification { 32 public static class DefaultStructureIdentificationAlgorithmOperators { 33 public static IOperator CreateFunctionLibraryInjector() { 34 CombinedOperator op = new CombinedOperator(); 35 op.Name = "FunctionLibraryInjector"; 36 SequentialProcessor seq = new SequentialProcessor(); 37 seq.AddSubOperator(new FunctionLibraryInjector()); 38 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 39 op.OperatorGraph.AddOperator(seq); 40 op.OperatorGraph.InitialOperator = seq; 41 return op; 42 } 43 28 namespace HeuristicLab.Modeling { 29 public static class DefaultRegressionOperators { 44 30 public static IOperator CreateProblemInjector() { 45 31 CombinedOperator op = new CombinedOperator(); … … 57 43 } 58 44 59 public static IOperator CreateInitialPopulationEvaluator() {60 MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();61 eval.Name = "Evaluator";62 eval.GetVariableInfo("MSE").ActualName = "Quality";63 eval.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";64 eval.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";65 return eval;66 }67 68 public static IOperator CreateEvaluator() {69 return CreateInitialPopulationEvaluator();70 }71 72 public static IOperator CreateGenerationStepHook() {73 CombinedOperator op = new CombinedOperator();74 SequentialProcessor seq = new SequentialProcessor();75 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();76 SequentialProcessor individualProc = new SequentialProcessor();77 MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();78 validationEvaluator.Name = "ValidationEvaluator";79 validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";80 validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";81 validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";82 83 individualProc.AddSubOperator(validationEvaluator);84 85 BestSolutionStorer solutionStorer = new BestSolutionStorer();86 solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";87 solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";88 89 BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();90 validationQualityCalculator.Name = "BestAverageWorstValidationQualityCalculator";91 validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";92 validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";93 validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";94 validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";95 96 subScopesProc.AddSubOperator(individualProc);97 98 seq.AddSubOperator(subScopesProc);99 seq.AddSubOperator(solutionStorer);100 seq.AddSubOperator(validationQualityCalculator);101 102 op.OperatorGraph.AddOperator(seq);103 op.OperatorGraph.InitialOperator = seq;104 return op;105 }106 107 45 public static IOperator CreatePostProcessingOperator() { 108 46 CombinedOperator op = new CombinedOperator(); 109 op.Name = " ModelAnalyser";47 op.Name = "Regression model analyser"; 110 48 SequentialProcessor seq = new SequentialProcessor(); 111 LeftReducer cleanUp = new LeftReducer();112 cleanUp.Name = "Reset Population";113 seq.AddSubOperator(cleanUp);114 115 SolutionExtractor extractor = new SolutionExtractor();116 extractor.GetVariableInfo("Scope").ActualName = "BestValidationSolution";117 SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor();118 SequentialProcessor solutionProc = new SequentialProcessor();119 120 seq.AddSubOperator(extractor);121 seq.AddSubOperator(seqSubScopeProc);122 seqSubScopeProc.AddSubOperator(solutionProc);123 124 HL3TreeEvaluatorInjector evaluatorInjector = new HL3TreeEvaluatorInjector();125 evaluatorInjector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000.0)));126 evaluatorInjector.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";127 128 #region simple evaluators129 SimpleEvaluator trainingEvaluator = new SimpleEvaluator();130 trainingEvaluator.Name = "TrainingEvaluator";131 trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";132 trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";133 trainingEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";134 trainingEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";135 SimpleEvaluator validationEvaluator = new SimpleEvaluator();136 validationEvaluator.Name = "ValidationEvaluator";137 validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";138 validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";139 validationEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";140 validationEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";141 SimpleEvaluator testEvaluator = new SimpleEvaluator();142 testEvaluator.Name = "TestEvaluator";143 testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";144 testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";145 testEvaluator.GetVariableInfo("Values").ActualName = "TestValues";146 testEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";147 #endregion148 49 #region MSE 149 50 SimpleMSEEvaluator trainingMseEvaluator = new SimpleMSEEvaluator(); … … 217 118 #endregion 218 119 219 solutionProc.AddSubOperator(evaluatorInjector); 220 solutionProc.AddSubOperator(trainingEvaluator); 221 solutionProc.AddSubOperator(validationEvaluator); 222 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); 120 seq.AddSubOperator(trainingMseEvaluator); 121 seq.AddSubOperator(validationMseEvaluator); 122 seq.AddSubOperator(testMseEvaluator); 123 seq.AddSubOperator(trainingMapeEvaluator); 124 seq.AddSubOperator(validationMapeEvaluator); 125 seq.AddSubOperator(testMapeEvaluator); 126 seq.AddSubOperator(trainingMapreEvaluator); 127 seq.AddSubOperator(validationMapreEvaluator); 128 seq.AddSubOperator(testMapreEvaluator); 129 seq.AddSubOperator(trainingR2Evaluator); 130 seq.AddSubOperator(validationR2Evaluator); 131 seq.AddSubOperator(testR2Evaluator); 132 seq.AddSubOperator(trainingVAFEvaluator); 133 seq.AddSubOperator(validationVAFEvaluator); 134 seq.AddSubOperator(testVAFEvaluator); 238 135 239 136 #region variable impacts 240 // calculate and set variable impacts241 VariableNamesExtractor namesExtractor = new VariableNamesExtractor();242 namesExtractor.GetVariableInfo("VariableNames").ActualName = "InputVariableNames";243 PredictorBuilder predictorBuilder = new PredictorBuilder();244 predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";245 246 137 VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator(); 247 138 evaluationImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; … … 251 142 qualityImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 252 143 253 solutionProc.AddSubOperator(namesExtractor); 254 solutionProc.AddSubOperator(predictorBuilder); 255 solutionProc.AddSubOperator(evaluationImpactCalculator); 256 solutionProc.AddSubOperator(qualityImpactCalculator); 144 seq.AddSubOperator(evaluationImpactCalculator); 145 seq.AddSubOperator(qualityImpactCalculator); 257 146 #endregion 258 147 … … 262 151 } 263 152 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); 153 public static IAnalyzerModel PopulateAnalyzerModel(IScope modelScope, IAnalyzerModel model) { 154 model.Predictor = modelScope.GetVariableValue<IPredictor>("Predictor", false); 155 Dataset ds = modelScope.GetVariableValue<Dataset>("Dataset", true); 268 156 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;157 model.TargetVariable = ds.GetVariableName(modelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 158 model.TrainingSamplesStart = modelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data; 159 model.TrainingSamplesEnd = modelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data; 160 model.ValidationSamplesStart = modelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data; 161 model.ValidationSamplesEnd = modelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data; 162 model.TestSamplesStart = modelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data; 163 model.TestSamplesEnd = modelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data; 276 164 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);165 model.SetResult("TrainingMeanSquaredError", modelScope.GetVariableValue<DoubleData>("TrainingMSE", false).Data); 166 model.SetResult("ValidationMeanSquaredError", modelScope.GetVariableValue<DoubleData>("ValidationMSE", false).Data); 167 model.SetResult("TestMeanSquaredError", modelScope.GetVariableValue<DoubleData>("TestMSE", false).Data); 168 model.SetResult("TrainingCoefficientOfDetermination", modelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data); 169 model.SetResult("ValidationCoefficientOfDetermination", modelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data); 170 model.SetResult("TestCoefficientOfDetermination", modelScope.GetVariableValue<DoubleData>("TestR2", false).Data); 171 model.SetResult("TrainingMeanAbsolutePercentageError", modelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data); 172 model.SetResult("ValidationMeanAbsolutePercentageError", modelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data); 173 model.SetResult("TestMeanAbsolutePercentageError", modelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data); 174 model.SetResult("TrainingMeanAbsolutePercentageOfRangeError", modelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data); 175 model.SetResult("ValidationMeanAbsolutePercentageOfRangeError", modelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data); 176 model.SetResult("TestMeanAbsolutePercentageOfRangeError", modelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data); 177 model.SetResult("TrainingVarianceAccountedFor", modelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data); 178 model.SetResult("ValidationVarianceAccountedFor", modelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data); 179 model.SetResult("TestVarianceAccountedFor", modelScope.GetVariableValue<DoubleData>("TestVAF", false).Data); 292 180 293 model.SetMetaData("EvaluatedSolutions", bestModelScope.GetVariableValue<DoubleData>("EvaluatedSolutions", true).Data); 294 IGeneticProgrammingModel gpModel = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("FunctionTree", true); 295 model.SetMetaData("TreeSize", gpModel.Size); 296 model.SetMetaData("TreeHeight", gpModel.Height); 297 298 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 299 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 181 ItemList evaluationImpacts = modelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 182 ItemList qualityImpacts = modelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 300 183 foreach (ItemList row in evaluationImpacts) { 301 184 string variableName = ((StringData)row[0]).Data; -
trunk/sources/HeuristicLab.Modeling/3.2/DefaultTimeSeriesOperators.cs
r2354 r2356 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.DataAnalysis; 24 using HeuristicLab.GP.Interfaces;25 24 using HeuristicLab.Operators; 26 25 using HeuristicLab.Modeling; 27 using HeuristicLab.Logging;28 26 using HeuristicLab.Data; 29 27 30 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 31 internal static class DefaultTimeSeriesOperators { 32 internal static IOperator CreateFunctionLibraryInjector() { 33 CombinedOperator op = new CombinedOperator(); 34 op.Name = "FunctionLibraryInjector"; 35 SequentialProcessor seq = new SequentialProcessor(); 36 FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector(); 37 funLibInjector.GetVariable("Differentials").Value = new BoolData(true); 38 seq.AddSubOperator(funLibInjector); 39 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 40 op.OperatorGraph.AddOperator(seq); 41 op.OperatorGraph.InitialOperator = seq; 42 return op; 43 } 44 45 internal static IOperator CreateProblemInjector() { 28 namespace HeuristicLab.Modeling { 29 public static class DefaultTimeSeriesOperators { 30 public static IOperator CreateProblemInjector() { 46 31 CombinedOperator op = new CombinedOperator(); 47 32 op.Name = "ProblemInjector"; … … 53 38 } 54 39 55 internal static IOperator CreatePostProcessingOperator() { 40 public static IOperator CreatePostProcessingOperator() { 41 CombinedOperator op = new CombinedOperator(); 42 op.Name = "Time series prognosis model analyzer"; 43 56 44 SequentialProcessor seq = new SequentialProcessor(); 57 seq.AddSubOperator(DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator()); 58 59 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor(); 60 SequentialProcessor individualProc = new SequentialProcessor(); 61 subScopesProc.AddSubOperator(individualProc); 62 seq.AddSubOperator(subScopesProc); 45 seq.AddSubOperator(DefaultRegressionOperators.CreatePostProcessingOperator()); 63 46 64 47 SimpleTheilInequalityCoefficientEvaluator trainingTheil = new SimpleTheilInequalityCoefficientEvaluator(); … … 75 58 testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient"; 76 59 77 individualProc.AddSubOperator(trainingTheil); 78 individualProc.AddSubOperator(validationTheil); 79 individualProc.AddSubOperator(testTheil); 80 return seq; 60 seq.AddSubOperator(trainingTheil); 61 seq.AddSubOperator(validationTheil); 62 seq.AddSubOperator(testTheil); 63 64 op.OperatorGraph.AddOperator(seq); 65 op.OperatorGraph.InitialOperator = seq; 66 return op; 81 67 } 82 68 83 internal static void SetModelData(IAnalyzerModel model, IScope scope) { 84 model.SetResult("TrainingTheilInequalityCoefficient", scope.GetVariableValue<DoubleData>("TrainingTheilInequalityCoefficient", true).Data); 85 model.SetResult("ValidationTheilInequalityCoefficient", scope.GetVariableValue<DoubleData>("ValidationTheilInequalityCoefficient", true).Data); 86 model.SetResult("TestTheilInequalityCoefficient", scope.GetVariableValue<DoubleData>("TestTheilInequalityCoefficient", true).Data); 69 public static IAnalyzerModel PopulateAnalyzerModel(IScope modelScope, IAnalyzerModel model) { 70 DefaultRegressionOperators.PopulateAnalyzerModel(modelScope, model); 71 model.SetResult("TrainingTheilInequalityCoefficient", modelScope.GetVariableValue<DoubleData>("TrainingTheilInequalityCoefficient", true).Data); 72 model.SetResult("ValidationTheilInequalityCoefficient", modelScope.GetVariableValue<DoubleData>("ValidationTheilInequalityCoefficient", true).Data); 73 model.SetResult("TestTheilInequalityCoefficient", modelScope.GetVariableValue<DoubleData>("TestTheilInequalityCoefficient", true).Data); 74 75 return model; 87 76 } 88 77 } -
trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
r2351 r2356 84 84 <Compile Include="AnalyzerModel.cs" /> 85 85 <Compile Include="BestSolutionStorer.cs" /> 86 <Compile Include="DefaultClassificationOperators.cs" /> 87 <Compile Include="DefaultRegressionOperators.cs" /> 88 <Compile Include="DefaultTimeSeriesOperators.cs" /> 86 89 <Compile Include="SimpleAccuracyEvaluator.cs" /> 87 90 <Compile Include="SimpleConfusionMatrixEvaluator.cs" /> … … 133 136 <Name>HeuristicLab.Data-3.2</Name> 134 137 </ProjectReference> 138 <ProjectReference Include="..\..\HeuristicLab.Operators\3.2\HeuristicLab.Operators-3.2.csproj"> 139 <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project> 140 <Name>HeuristicLab.Operators-3.2</Name> 141 </ProjectReference> 135 142 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 136 143 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorClassification.cs
r2351 r2356 1 #region License Information 1 2 #region License Information 2 3 /* HeuristicLab 3 4 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 37 38 38 39 namespace HeuristicLab.SupportVectorMachines { 39 public class SupportVectorClassification : SupportVectorRegression {40 public class SupportVectorClassification : SupportVectorRegression, IClassificationAlgorithm { 40 41 41 42 public override string Name { get { return "SupportVectorClassification"; } } … … 48 49 } 49 50 50 protected override IOperator CreateModelAnalyser() { 51 CombinedOperator op = new CombinedOperator(); 52 op.Name = "Model Analyzer"; 53 SequentialProcessor seq = new SequentialProcessor(); 54 seq.AddSubOperator(base.CreateModelAnalyser()); 55 SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor(); 56 SequentialProcessor seqProc = new SequentialProcessor(); 57 58 SupportVectorEvaluator trainingEvaluator = new SupportVectorEvaluator(); 59 trainingEvaluator.Name = "TrainingSimpleEvaluator"; 60 trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 61 trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 62 trainingEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 63 64 SimpleAccuracyEvaluator trainingAccuracyEvaluator = new SimpleAccuracyEvaluator(); 65 trainingAccuracyEvaluator.Name = "TrainingAccuracyEvaluator"; 66 trainingAccuracyEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 67 trainingAccuracyEvaluator.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy"; 68 SimpleAccuracyEvaluator validationAccuracyEvaluator = new SimpleAccuracyEvaluator(); 69 validationAccuracyEvaluator.Name = "ValidationAccuracyEvaluator"; 70 validationAccuracyEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues"; 71 validationAccuracyEvaluator.GetVariableInfo("Accuracy").ActualName = "ValidationAccuracy"; 72 SimpleAccuracyEvaluator testAccuracyEvaluator = new SimpleAccuracyEvaluator(); 73 testAccuracyEvaluator.Name = "TestAccuracyEvaluator"; 74 testAccuracyEvaluator.GetVariableInfo("Values").ActualName = "TestValues"; 75 testAccuracyEvaluator.GetVariableInfo("Accuracy").ActualName = "TestAccuracy"; 76 77 SimpleConfusionMatrixEvaluator trainingConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 78 trainingConfusionMatrixEvaluator.Name = "TrainingConfusionMatrixEvaluator"; 79 trainingConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 80 trainingConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "TrainingConfusionMatrix"; 81 SimpleConfusionMatrixEvaluator validationConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 82 validationConfusionMatrixEvaluator.Name = "ValidationConfusionMatrixEvaluator"; 83 validationConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues"; 84 validationConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "ValidationConfusionMatrix"; 85 SimpleConfusionMatrixEvaluator testConfusionMatrixEvaluator = new SimpleConfusionMatrixEvaluator(); 86 testConfusionMatrixEvaluator.Name = "TestConfusionMatrixEvaluator"; 87 testConfusionMatrixEvaluator.GetVariableInfo("Values").ActualName = "TestValues"; 88 testConfusionMatrixEvaluator.GetVariableInfo("ConfusionMatrix").ActualName = "TestConfusionMatrix"; 89 90 seqProc.AddSubOperator(trainingEvaluator); 91 seqProc.AddSubOperator(trainingAccuracyEvaluator); 92 seqProc.AddSubOperator(validationAccuracyEvaluator); 93 seqProc.AddSubOperator(testAccuracyEvaluator); 94 seqProc.AddSubOperator(trainingConfusionMatrixEvaluator); 95 seqProc.AddSubOperator(validationConfusionMatrixEvaluator); 96 seqProc.AddSubOperator(testConfusionMatrixEvaluator); 97 98 seq.AddSubOperator(seqSubScopeProc); 99 seqSubScopeProc.AddSubOperator(seqProc); 100 101 op.OperatorGraph.AddOperator(seq); 102 op.OperatorGraph.InitialOperator = seq; 103 return op; 51 protected override IOperator CreateModelAnalyzerOperator() { 52 return DefaultClassificationOperators.CreatePostProcessingOperator(); 104 53 } 105 54 106 55 107 56 protected override IAnalyzerModel CreateSVMModel(IScope bestModelScope) { 108 IAnalyzerModel model = base.CreateSVMModel(bestModelScope); 109 110 model.SetResult("TrainingAccuracy", bestModelScope.GetVariableValue<DoubleData>("TrainingAccuracy", false).Data); 111 model.SetResult("ValidationAccuracy", bestModelScope.GetVariableValue<DoubleData>("ValidationAccuracy", false).Data); 112 model.SetResult("TestAccuracy", bestModelScope.GetVariableValue<DoubleData>("TestAccuracy", false).Data); 113 57 IAnalyzerModel model = new AnalyzerModel(); 58 model.SetMetaData("Cost", bestModelScope.GetVariableValue<DoubleData>("Cost", false).Data); 59 model.SetMetaData("Nu", bestModelScope.GetVariableValue<DoubleData>("Nu", false).Data); 60 DefaultClassificationOperators.PopulateAnalyzerModel(bestModelScope, model); 114 61 return model; 115 62 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs
r2351 r2356 125 125 CombinedOperator algo = new CombinedOperator(); 126 126 SequentialProcessor seq = new SequentialProcessor(); 127 algo.Name = "SupportVectorRegression";128 seq.Name = "SupportVectorRegression";127 algo.Name = Name; 128 seq.Name = Name; 129 129 130 130 IOperator initialization = CreateInitialization(); 131 131 IOperator main = CreateMainLoop(); 132 IOperator postProc = Create ModelAnalyser();132 IOperator postProc = CreatePostProcessingOperator(); 133 133 134 134 seq.AddSubOperator(initialization); … … 145 145 SequentialProcessor seq = new SequentialProcessor(); 146 146 seq.Name = "Initialization"; 147 seq.AddSubOperator(new RandomInjector()); 147 148 seq.AddSubOperator(CreateGlobalInjector()); 148 ProblemInjector probInjector = new ProblemInjector(); 149 probInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true; 150 probInjector.AddVariable(new Variable("MaxNumberOfTrainingSamples", new IntData(1000))); 151 seq.AddSubOperator(probInjector); 152 seq.AddSubOperator(new RandomInjector()); 153 154 DatasetShuffler shuffler = new DatasetShuffler(); 155 shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart"; 156 shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd"; 157 seq.AddSubOperator(shuffler); 149 seq.AddSubOperator(CreateProblemInjector()); 158 150 return seq; 151 } 152 153 protected virtual IOperator CreateProblemInjector() { 154 return DefaultRegressionOperators.CreateProblemInjector(); 159 155 } 160 156 … … 402 398 } 403 399 404 protected virtual IOperator Create ModelAnalyser() {400 protected virtual IOperator CreatePostProcessingOperator() { 405 401 CombinedOperator modelAnalyser = new CombinedOperator(); 406 402 modelAnalyser.Name = "Model Analyzer"; … … 410 406 PredictorBuilder predictorBuilder = new PredictorBuilder(); 411 407 predictorBuilder.GetVariableInfo("SVMModel").ActualName = "Model"; 412 VariableEvaluationImpactCalculator evalImpactCalc = new VariableEvaluationImpactCalculator();413 evalImpactCalc.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";414 evalImpactCalc.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";415 VariableQualityImpactCalculator qualImpactCalc = new VariableQualityImpactCalculator();416 qualImpactCalc.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";417 qualImpactCalc.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";418 408 419 409 seqProc.AddSubOperator(CreateEvaluator("Test")); 410 seqProc.AddSubOperator(CreateEvaluator("Training")); 420 411 seqProc.AddSubOperator(predictorBuilder); 421 seqProc.AddSubOperator( evalImpactCalc);422 seqProc.AddSubOperator(qualImpactCalc); 412 seqProc.AddSubOperator(CreateModelAnalyzerOperator()); 413 423 414 seqSubScopeProc.AddSubOperator(seqProc); 424 415 modelAnalyser.OperatorGraph.InitialOperator = seqSubScopeProc; … … 427 418 } 428 419 420 protected virtual IOperator CreateModelAnalyzerOperator() { 421 return DefaultRegressionOperators.CreatePostProcessingOperator(); 422 } 423 429 424 430 425 protected virtual IAnalyzerModel CreateSVMModel(IScope bestModelScope) { 431 426 AnalyzerModel model = new AnalyzerModel(); 432 model.SetResult("TrainingMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data);433 model.SetResult("ValidationMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data);434 model.SetResult("TestMeanSquaredError", bestModelScope.GetVariableValue<DoubleData>("TestQuality", false).Data);435 model.SetResult("TrainingCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingR2", false).Data);436 model.SetResult("ValidationCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data);437 model.SetResult("TestCoefficientOfDetermination", bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data);438 model.SetResult("TrainingMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPE", false).Data);439 model.SetResult("ValidationMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data);440 model.SetResult("TestMeanAbsolutePercentageError", bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data);441 model.SetResult("TrainingMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPRE", false).Data);442 model.SetResult("ValidationMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data);443 model.SetResult("TestMeanAbsolutePercentageOfRangeError", bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data);444 model.SetResult("TrainingVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("ActualTrainingVAF", false).Data);445 model.SetResult("ValidationVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data);446 model.SetResult("TestVarianceAccountedFor", bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data);447 448 427 model.SetMetaData("Cost", bestModelScope.GetVariableValue<DoubleData>("Cost", false).Data); 449 428 model.SetMetaData("Nu", bestModelScope.GetVariableValue<DoubleData>("Nu", false).Data); 450 451 HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 452 model.Dataset = ds; 453 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 454 model.TrainingSamplesStart = bestModelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data; 455 model.TrainingSamplesEnd = bestModelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data; 456 model.ValidationSamplesStart = bestModelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data; 457 model.ValidationSamplesEnd = bestModelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data; 458 model.TestSamplesStart = bestModelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data; 459 model.TestSamplesEnd = bestModelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data; 460 model.Predictor = bestModelScope.GetVariableValue<IPredictor>("Predictor", true); 461 462 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 463 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 464 foreach (ItemList row in evaluationImpacts) { 465 string variableName = ((StringData)row[0]).Data; 466 double impact = ((DoubleData)row[1]).Data; 467 model.SetVariableEvaluationImpact(variableName, impact); 468 model.AddInputVariable(variableName); 469 } 470 foreach (ItemList row in qualityImpacts) { 471 string variableName = ((StringData)row[0]).Data; 472 double impact = ((DoubleData)row[1]).Data; 473 model.SetVariableQualityImpact(variableName, impact); 474 model.AddInputVariable(variableName); 475 } 429 DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model); 476 430 477 431 return model; … … 479 433 480 434 protected IOperator GetVariableInjector() { 481 return GetMainOperator().SubOperators[0].SubOperators[ 0];435 return GetMainOperator().SubOperators[0].SubOperators[1]; 482 436 } 483 437 -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/TimeSeriesSupportVectorRegression.cs
r2354 r2356 57 57 } 58 58 59 protected override IOperator CreateInitialization() { 60 SequentialProcessor seq = new SequentialProcessor(); 61 seq.Name = "Initialization"; 62 seq.AddSubOperator(CreateGlobalInjector()); 63 ProblemInjector probInjector = new ProblemInjector(); 64 seq.AddSubOperator(probInjector); 65 seq.AddSubOperator(new RandomInjector()); 66 return seq; 59 protected override IOperator CreateProblemInjector() { 60 return DefaultTimeSeriesOperators.CreateProblemInjector(); 67 61 } 68 62 … … 74 68 } 75 69 76 protected override IOperator CreateModelAnalyser() { 77 CombinedOperator op = new CombinedOperator(); 78 op.Name = "Model Analyzer"; 79 SequentialProcessor seq = new SequentialProcessor(); 80 seq.AddSubOperator(base.CreateModelAnalyser()); 81 SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor(); 82 SequentialProcessor seqProc = new SequentialProcessor(); 83 84 SupportVectorEvaluator trainingEvaluator = new SupportVectorEvaluator(); 85 trainingEvaluator.Name = "TrainingEvaluator"; 86 trainingEvaluator.GetVariableInfo("SVMModel").ActualName = "Model"; 87 trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 88 trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 89 trainingEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues"; 90 91 SimpleTheilInequalityCoefficientEvaluator trainingTheilUCalculator = new SimpleTheilInequalityCoefficientEvaluator(); 92 trainingTheilUCalculator.Name = "TrainingTheilInequalityEvaluator"; 93 trainingTheilUCalculator.GetVariableInfo("Values").ActualName = "TrainingValues"; 94 trainingTheilUCalculator.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient"; 95 SimpleTheilInequalityCoefficientEvaluator validationTheilUCalculator = new SimpleTheilInequalityCoefficientEvaluator(); 96 validationTheilUCalculator.Name = "ValidationTheilInequalityEvaluator"; 97 validationTheilUCalculator.GetVariableInfo("Values").ActualName = "ValidationValues"; 98 validationTheilUCalculator.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient"; 99 SimpleTheilInequalityCoefficientEvaluator testTheilUCalculator = new SimpleTheilInequalityCoefficientEvaluator(); 100 testTheilUCalculator.Name = "TestTheilInequalityEvaluator"; 101 testTheilUCalculator.GetVariableInfo("Values").ActualName = "TestValues"; 102 testTheilUCalculator.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient"; 103 104 seqProc.AddSubOperator(trainingEvaluator); 105 seqProc.AddSubOperator(trainingTheilUCalculator); 106 seqProc.AddSubOperator(validationTheilUCalculator); 107 seqProc.AddSubOperator(testTheilUCalculator); 108 109 seq.AddSubOperator(seqSubScopeProc); 110 seqSubScopeProc.AddSubOperator(seqProc); 111 112 op.OperatorGraph.AddOperator(seq); 113 op.OperatorGraph.InitialOperator = seq; 114 return op; 70 protected override IOperator CreateModelAnalyzerOperator() { 71 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 115 72 } 116 73 117 118 74 protected override IAnalyzerModel CreateSVMModel(IScope bestModelScope) { 119 IAnalyzerModel model = base.CreateSVMModel(bestModelScope); 120 121 model.SetResult("TrainingTheilInequalityCoefficient", bestModelScope.GetVariableValue<DoubleData>("TrainingTheilInequalityCoefficient", false).Data); 122 model.SetResult("ValidationTheilInequalityCoefficient", bestModelScope.GetVariableValue<DoubleData>("ValidationTheilInequalityCoefficient", false).Data); 123 model.SetResult("TestTheilInequalityCoefficient", bestModelScope.GetVariableValue<DoubleData>("TestTheilInequalityCoefficient", false).Data); 124 75 var model = new AnalyzerModel(); 76 model.SetMetaData("Cost", bestModelScope.GetVariableValue<DoubleData>("Cost", false).Data); 77 model.SetMetaData("Nu", bestModelScope.GetVariableValue<DoubleData>("Nu", false).Data); 78 DefaultTimeSeriesOperators.PopulateAnalyzerModel(bestModelScope, model); 125 79 return model; 126 80 }
Note: See TracChangeset
for help on using the changeset viewer.