Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2356


Ignore:
Timestamp:
09/15/09 14:01:47 (15 years ago)
Author:
gkronber
Message:

Moved common (not algorithm specific) model analyzer code (same operator tree in all regression/classification/time-series-prognosis engines) to HL.Modeling. #625, #705, #739.

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  
    8181  <ItemGroup>
    8282    <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" />
    83     <Compile Include="DefaultClassificationAlgorithmOperators.cs" />
    8483    <Compile Include="GPClassificationEvaluatorBase.cs" />
    8584    <Compile Include="CrossValidation.cs" />
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs

    r2344 r2356  
    2323using HeuristicLab.Modeling;
    2424using HeuristicLab.Operators;
     25using HeuristicLab.Data;
    2526
    2627namespace HeuristicLab.GP.StructureIdentification.Classification {
    2728  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm {
    2829
    29     protected override IOperator CreateProblemInjector() {
    30       return DefaultClassificationAlgorithmOperators.CreateProblemInjector();
     30    public override string Name {
     31      get {
     32        return base.Name + " - Classification";
     33      }
    3134    }
    3235
    33     protected override IOperator CreatePostProcessingOperator() {
    34       return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator();
     36    protected override IOperator CreateProblemInjector() {
     37      return DefaultClassificationOperators.CreateProblemInjector();
    3538    }
    3639
    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
    4052      return model;
    4153    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs

    r2344 r2356  
    2727namespace HeuristicLab.GP.StructureIdentification.Classification {
    2828  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm {
     29    public override string Name {
     30      get {
     31        return base.Name + " - Classification";
     32      }
     33    }
     34
    2935    protected override IOperator CreateProblemInjector() {
    30       return DefaultClassificationAlgorithmOperators.CreateProblemInjector();
     36      return DefaultClassificationOperators.CreateProblemInjector();
    3137    }
    32    
    33     protected override IOperator CreatePostProcessingOperator() {
    34       return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator();
     38
     39    protected override IOperator CreateModelAnalyzerOperator() {
     40      return DefaultClassificationOperators.CreatePostProcessingOperator();
    3541    }
    3642
    3743    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);
    4048      return model;
    4149    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj

    r2352 r2356  
    8383  <ItemGroup>
    8484    <Compile Include="AveragePercentageChangeEvaluator.cs" />
    85     <Compile Include="DefaultTimeSeriesOperators.cs" />
    8685    <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" />
    8786    <Compile Include="OffspringSelectionGP.cs" />
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs

    r2344 r2356  
    2929namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3030  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm {
     31    public override string Name {
     32      get {
     33        return base.Name + " - time series prognosis";
     34      }
     35    }
    3136
    3237    public int MinTimeOffset {
     
    5055
    5156    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;
    5767    }
    5868
     
    6575    }
    6676
     77    protected override IOperator CreateModelAnalyzerOperator() {
     78      return DefaultTimeSeriesOperators.CreatePostProcessingOperator();
     79    }
     80
    6781    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);
    7087      return model;
    7188    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs

    r2344 r2356  
    2929namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3030  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
    3137    public int MinTimeOffset {
    3238      get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; }
     
    4955
    5056    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;
    5267    }
    5368
    54     protected override IOperator CreatePostProcessingOperator() {
     69    protected override IOperator CreateModelAnalyzerOperator() {
    5570      return DefaultTimeSeriesOperators.CreatePostProcessingOperator();
    5671    }
     
    6580
    6681    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);
    6986      return model;
    7087    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs

    r2351 r2356  
    3030
    3131namespace HeuristicLab.GP.StructureIdentification {
    32   public static class DefaultStructureIdentificationAlgorithmOperators {
     32  public static class DefaultStructureIdentificationOperators {
    3333    public static IOperator CreateFunctionLibraryInjector() {
    3434      CombinedOperator op = new CombinedOperator();
     
    3737      seq.AddSubOperator(new FunctionLibraryInjector());
    3838      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);
    5439      op.OperatorGraph.AddOperator(seq);
    5540      op.OperatorGraph.InitialOperator = seq;
     
    10590    }
    10691
    107     public static IOperator CreatePostProcessingOperator() {
    108       CombinedOperator op = new CombinedOperator();
    109       op.Name = "ModelAnalyser";
     92
     93    public static IOperator CreatePreparationForPostProcessingOperator() {
    11094      SequentialProcessor seq = new SequentialProcessor();
    11195      LeftReducer cleanUp = new LeftReducer();
     
    145129      testEvaluator.GetVariableInfo("Values").ActualName = "TestValues";
    146130      testEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
    147       #endregion
    148       #region MSE
    149       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       #endregion
    162       #region MAPE
    163       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       #endregion
    176       #region MAPRE
    177       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 MAPRE
    190       #region R2
    191       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       #endregion
    204       #region VAF
    205       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       #endregion
    218 
    219131      solutionProc.AddSubOperator(evaluatorInjector);
    220132      solutionProc.AddSubOperator(trainingEvaluator);
    221133      solutionProc.AddSubOperator(validationEvaluator);
    222134      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
    238136
    239137      #region variable impacts
     
    244142      predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
    245143
    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 
    253144      solutionProc.AddSubOperator(namesExtractor);
    254145      solutionProc.AddSubOperator(predictorBuilder);
    255       solutionProc.AddSubOperator(evaluationImpactCalculator);
    256       solutionProc.AddSubOperator(qualityImpactCalculator);
    257146      #endregion
    258147
    259       op.OperatorGraph.AddOperator(seq);
    260       op.OperatorGraph.InitialOperator = seq;
    261       return op;
     148      return seq;
    262149    }
    263150
    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);
    295154      model.SetMetaData("TreeSize", gpModel.Size);
    296155      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;
    314156    }
    315157  }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGP.cs

    r2344 r2356  
    7777
    7878    protected override IOperator CreateFunctionLibraryInjector() {
    79       return DefaultStructureIdentificationAlgorithmOperators.CreateFunctionLibraryInjector();
     79      return DefaultStructureIdentificationOperators.CreateFunctionLibraryInjector();
    8080    }
    8181
    8282    protected override IOperator CreateProblemInjector() {
    83       return DefaultStructureIdentificationAlgorithmOperators.CreateProblemInjector();
     83      return DefaultRegressionOperators.CreateProblemInjector();
    8484    }
    8585
    8686    protected override IOperator CreateInitialPopulationEvaluator() {
    87       return DefaultStructureIdentificationAlgorithmOperators.CreateInitialPopulationEvaluator();
     87      return DefaultStructureIdentificationOperators.CreateInitialPopulationEvaluator();
    8888    }
    8989
    9090    protected override IOperator CreateEvaluationOperator() {
    91       return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();
     91      return DefaultStructureIdentificationOperators.CreateEvaluator();
    9292    }
    9393
    9494
    9595    protected override IOperator CreateGenerationStepHook() {
    96       return DefaultStructureIdentificationAlgorithmOperators.CreateGenerationStepHook();
     96      return DefaultStructureIdentificationOperators.CreateGenerationStepHook();
    9797    }
    9898
     
    133133
    134134    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();
    136154    }
    137155
     
    148166    protected virtual IAnalyzerModel CreateGPModel() {
    149167      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
    152174      return model;
    153175    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs

    r2344 r2356  
    7878
    7979    protected override IOperator CreateFunctionLibraryInjector() {
    80       return DefaultStructureIdentificationAlgorithmOperators.CreateFunctionLibraryInjector();
     80      return DefaultStructureIdentificationOperators.CreateFunctionLibraryInjector();
    8181    }
    8282
    8383    protected override IOperator CreateProblemInjector() {
    84       return DefaultStructureIdentificationAlgorithmOperators.CreateProblemInjector();
     84      return DefaultRegressionOperators.CreateProblemInjector();
    8585    }
    8686
    8787    protected override IOperator CreateInitialPopulationEvaluator() {
    88       return DefaultStructureIdentificationAlgorithmOperators.CreateInitialPopulationEvaluator();
     88      return DefaultStructureIdentificationOperators.CreateInitialPopulationEvaluator();
    8989    }
    9090
    9191    protected override IOperator CreateEvaluationOperator() {
    92       return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();
     92      return DefaultStructureIdentificationOperators.CreateEvaluator();
    9393    }
    9494
    9595
    9696    protected override IOperator CreateGenerationStepHook() {
    97       return DefaultStructureIdentificationAlgorithmOperators.CreateGenerationStepHook();
     97      return DefaultStructureIdentificationOperators.CreateGenerationStepHook();
    9898    }
    9999
     
    132132
    133133    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();
    135153    }
    136154
     
    147165    protected virtual IAnalyzerModel CreateGPModel() {
    148166      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);
    150170      return model;
    151171    }
  • trunk/sources/HeuristicLab.LinearRegression/3.2/LinearClassification.cs

    r2353 r2356  
    3838
    3939namespace HeuristicLab.LinearRegression {
    40   public class LinearClassification : LinearRegression {
     40  public class LinearClassification : LinearRegression, IClassificationAlgorithm {
    4141
    4242    public override string Name { get { return "LinearClassification"; } }
     
    4646    }
    4747
    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();
    5054    }
    5155
    5256    protected internal virtual IAnalyzerModel CreateLRModel(IScope bestModelScope) {
    53       IAnalyzerModel model = base.CreateLRModel(bestModelScope);
    54       DefaultClassificationAlgorithmOperators.SetModelData(model, bestModelScope);
     57      var model = new AnalyzerModel();
     58      DefaultClassificationOperators.PopulateAnalyzerModel(bestModelScope, model);
    5559      return model;
    5660    }
  • trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs

    r2353 r2356  
    8787      CombinedOperator algo = new CombinedOperator();
    8888      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
    9492      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
    10496
    10597      LinearRegressionOperator lrOperator = new LinearRegressionOperator();
     
    10799      lrOperator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    108100
    109       seq.AddSubOperator(randomInjector);
    110       seq.AddSubOperator(problemInjector);
    111101      seq.AddSubOperator(globalInjector);
     102      seq.AddSubOperator(new RandomInjector());
     103      seq.AddSubOperator(CreateProblemInjector());
    112104      seq.AddSubOperator(treeEvaluatorInjector);
    113       seq.AddSubOperator(shuffler);
    114105      seq.AddSubOperator(lrOperator);
    115       seq.AddSubOperator(CreateModelAnalyser());
     106      seq.AddSubOperator(CreatePostProcessingOperator());
    116107
    117108      algo.OperatorGraph.InitialOperator = seq;
     
    119110
    120111      return algo;
     112    }
     113
     114    protected virtual IOperator CreateProblemInjector() {
     115      return DefaultRegressionOperators.CreateProblemInjector();
    121116    }
    122117
     
    129124    }
    130125
    131     protected virtual IOperator CreateModelAnalyser() {
     126    protected virtual IOperator CreatePostProcessingOperator() {
    132127      CombinedOperator op = new CombinedOperator();
    133       op.AddVariableInfo(new VariableInfo("FunctionTree", "The model to analyze", typeof(IGeneticProgrammingModel), VariableKind.In));
    134128      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;
    140181      return op;
    141182    }
    142183
     184    protected virtual IOperator CreateModelAnalyzerOperator() {
     185      return DefaultRegressionOperators.CreatePostProcessingOperator();
     186    }
     187
    143188    protected virtual IAnalyzerModel CreateLRModel(IScope bestModelScope) {
    144       return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope);
     189      var model = new AnalyzerModel();
     190      DefaultRegressionOperators.PopulateAnalyzerModel(bestModelScope, model);
     191      return model;
    145192    }
    146193
  • trunk/sources/HeuristicLab.Modeling/3.2/DefaultClassificationOperators.cs

    r2354 r2356  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.DataAnalysis;
    24 using HeuristicLab.GP.Interfaces;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Modeling;
    2726using HeuristicLab.Data;
    2827
    29 namespace HeuristicLab.GP.StructureIdentification.Classification {
    30   public static class DefaultClassificationAlgorithmOperators {
     28namespace HeuristicLab.Modeling {
     29  public static class DefaultClassificationOperators {
    3130    public static IOperator CreatePostProcessingOperator() {
     31      CombinedOperator op = new CombinedOperator();
     32      op.Name = "Classification model analyzer";
     33
    3234      SequentialProcessor seq = new SequentialProcessor();
    33       seq.AddSubOperator(DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator());
     35      seq.AddSubOperator(DefaultRegressionOperators.CreatePostProcessingOperator());
    3436
    35       UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
    36       SequentialProcessor individualProc = new SequentialProcessor();
    37       subScopesProc.AddSubOperator(individualProc);
    38       seq.AddSubOperator(subScopesProc);
    3937      SimpleAccuracyEvaluator trainingAccuracy = new SimpleAccuracyEvaluator();
    4038      trainingAccuracy.Name = "TrainingAccuracyEvaluator";
     
    5250      testAccuracy.GetVariableInfo("Values").ActualName = "TestValues";
    5351
    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;
    5876    }
    5977
    6078    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();
    6980    }
    7081
    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;
    7588    }
    7689  }
  • trunk/sources/HeuristicLab.Modeling/3.2/DefaultRegressionOperators.cs

    r2354 r2356  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.DataAnalysis;
    24 using HeuristicLab.GP.Interfaces;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Modeling;
    27 using HeuristicLab.Logging;
    28 using HeuristicLab.Selection;
    2926using HeuristicLab.Data;
    3027
    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 
     28namespace HeuristicLab.Modeling {
     29  public static class DefaultRegressionOperators {
    4430    public static IOperator CreateProblemInjector() {
    4531      CombinedOperator op = new CombinedOperator();
     
    5743    }
    5844
    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 
    10745    public static IOperator CreatePostProcessingOperator() {
    10846      CombinedOperator op = new CombinedOperator();
    109       op.Name = "ModelAnalyser";
     47      op.Name = "Regression model analyser";
    11048      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 evaluators
    129       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       #endregion
    14849      #region MSE
    14950      SimpleMSEEvaluator trainingMseEvaluator = new SimpleMSEEvaluator();
     
    217118      #endregion
    218119
    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);
    238135
    239136      #region variable impacts
    240       // calculate and set variable impacts
    241       VariableNamesExtractor namesExtractor = new VariableNamesExtractor();
    242       namesExtractor.GetVariableInfo("VariableNames").ActualName = "InputVariableNames";
    243       PredictorBuilder predictorBuilder = new PredictorBuilder();
    244       predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
    245 
    246137      VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator();
    247138      evaluationImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     
    251142      qualityImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
    252143
    253       solutionProc.AddSubOperator(namesExtractor);
    254       solutionProc.AddSubOperator(predictorBuilder);
    255       solutionProc.AddSubOperator(evaluationImpactCalculator);
    256       solutionProc.AddSubOperator(qualityImpactCalculator);
     144      seq.AddSubOperator(evaluationImpactCalculator);
     145      seq.AddSubOperator(qualityImpactCalculator);
    257146      #endregion
    258147
     
    262151    }
    263152
    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);
    268156      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;
    276164
    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);
    292180
    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);
    300183      foreach (ItemList row in evaluationImpacts) {
    301184        string variableName = ((StringData)row[0]).Data;
  • trunk/sources/HeuristicLab.Modeling/3.2/DefaultTimeSeriesOperators.cs

    r2354 r2356  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.DataAnalysis;
    24 using HeuristicLab.GP.Interfaces;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Modeling;
    27 using HeuristicLab.Logging;
    2826using HeuristicLab.Data;
    2927
    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() {
     28namespace HeuristicLab.Modeling {
     29  public static class DefaultTimeSeriesOperators {
     30    public static IOperator CreateProblemInjector() {
    4631      CombinedOperator op = new CombinedOperator();
    4732      op.Name = "ProblemInjector";
     
    5338    }
    5439
    55     internal static IOperator CreatePostProcessingOperator() {
     40    public static IOperator CreatePostProcessingOperator() {
     41      CombinedOperator op = new CombinedOperator();
     42      op.Name = "Time series prognosis model analyzer";
     43
    5644      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());
    6346
    6447      SimpleTheilInequalityCoefficientEvaluator trainingTheil = new SimpleTheilInequalityCoefficientEvaluator();
     
    7558      testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient";
    7659
    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;
    8167    }
    8268
    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;
    8776    }
    8877  }
  • trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj

    r2351 r2356  
    8484    <Compile Include="AnalyzerModel.cs" />
    8585    <Compile Include="BestSolutionStorer.cs" />
     86    <Compile Include="DefaultClassificationOperators.cs" />
     87    <Compile Include="DefaultRegressionOperators.cs" />
     88    <Compile Include="DefaultTimeSeriesOperators.cs" />
    8689    <Compile Include="SimpleAccuracyEvaluator.cs" />
    8790    <Compile Include="SimpleConfusionMatrixEvaluator.cs" />
     
    133136      <Name>HeuristicLab.Data-3.2</Name>
    134137    </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>
    135142    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    136143      <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
    23/* HeuristicLab
    34 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    3738
    3839namespace HeuristicLab.SupportVectorMachines {
    39   public class SupportVectorClassification : SupportVectorRegression {
     40  public class SupportVectorClassification : SupportVectorRegression, IClassificationAlgorithm {
    4041
    4142    public override string Name { get { return "SupportVectorClassification"; } }
     
    4849    }
    4950
    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();
    10453    }
    10554
    10655
    10756    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);
    11461      return model;
    11562    }
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs

    r2351 r2356  
    125125      CombinedOperator algo = new CombinedOperator();
    126126      SequentialProcessor seq = new SequentialProcessor();
    127       algo.Name = "SupportVectorRegression";
    128       seq.Name = "SupportVectorRegression";
     127      algo.Name = Name;
     128      seq.Name = Name;
    129129
    130130      IOperator initialization = CreateInitialization();
    131131      IOperator main = CreateMainLoop();
    132       IOperator postProc = CreateModelAnalyser();
     132      IOperator postProc = CreatePostProcessingOperator();
    133133
    134134      seq.AddSubOperator(initialization);
     
    145145      SequentialProcessor seq = new SequentialProcessor();
    146146      seq.Name = "Initialization";
     147      seq.AddSubOperator(new RandomInjector());
    147148      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());
    158150      return seq;
     151    }
     152
     153    protected virtual IOperator CreateProblemInjector() {
     154      return DefaultRegressionOperators.CreateProblemInjector();
    159155    }
    160156
     
    402398    }
    403399
    404     protected virtual IOperator CreateModelAnalyser() {
     400    protected virtual IOperator CreatePostProcessingOperator() {
    405401      CombinedOperator modelAnalyser = new CombinedOperator();
    406402      modelAnalyser.Name = "Model Analyzer";
     
    410406      PredictorBuilder predictorBuilder = new PredictorBuilder();
    411407      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";
    418408
    419409      seqProc.AddSubOperator(CreateEvaluator("Test"));
     410      seqProc.AddSubOperator(CreateEvaluator("Training"));
    420411      seqProc.AddSubOperator(predictorBuilder);
    421       seqProc.AddSubOperator(evalImpactCalc);
    422       seqProc.AddSubOperator(qualImpactCalc);
     412      seqProc.AddSubOperator(CreateModelAnalyzerOperator());
     413
    423414      seqSubScopeProc.AddSubOperator(seqProc);
    424415      modelAnalyser.OperatorGraph.InitialOperator = seqSubScopeProc;
     
    427418    }
    428419
     420    protected virtual IOperator CreateModelAnalyzerOperator() {
     421      return DefaultRegressionOperators.CreatePostProcessingOperator();
     422    }
     423
    429424
    430425    protected virtual IAnalyzerModel CreateSVMModel(IScope bestModelScope) {
    431426      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 
    448427      model.SetMetaData("Cost", bestModelScope.GetVariableValue<DoubleData>("Cost", false).Data);
    449428      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);
    476430
    477431      return model;
     
    479433
    480434    protected IOperator GetVariableInjector() {
    481       return GetMainOperator().SubOperators[0].SubOperators[0];
     435      return GetMainOperator().SubOperators[0].SubOperators[1];
    482436    }
    483437
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/TimeSeriesSupportVectorRegression.cs

    r2354 r2356  
    5757    }
    5858
    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();
    6761    }
    6862
     
    7468    }
    7569
    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();
    11572    }
    11673
    117 
    11874    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);
    12579      return model;
    12680    }
Note: See TracChangeset for help on using the changeset viewer.