Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2161


Ignore:
Timestamp:
07/15/09 16:23:29 (15 years ago)
Author:
gkronber
Message:

Implemented #704 (Shuffling of training data (only) in (non-timeseries) modeling algorithms)

Location:
trunk/sources
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs

    r1857 r2161  
    3434namespace HeuristicLab.GP.StructureIdentification.Classification {
    3535  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm {
    36     protected override IOperator CreateProblemInjector() {
    37       return new ProblemInjector();
    38     }
    3936
    4037    protected override IOperator CreateBestSolutionProcessor() {
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs

    r1857 r2161  
    3535namespace HeuristicLab.GP.StructureIdentification.Classification {
    3636  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm {
    37     protected override IOperator CreateProblemInjector() {
    38       return new ProblemInjector();
    39     }
    40 
    4137    protected override IOperator CreateBestSolutionProcessor() {
    4238      IOperator seq = base.CreateBestSolutionProcessor();
     
    5046        AccuracyEvaluator trainingAccuracy = new AccuracyEvaluator();
    5147        trainingAccuracy.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy";
    52         trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    53         trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     48        trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     49        trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    5450
    5551        AccuracyEvaluator validationAccuracy = new AccuracyEvaluator();
     
    6561        ConfusionMatrixEvaluator trainingConfusionMatrix = new ConfusionMatrixEvaluator();
    6662        trainingConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "TrainingConfusionMatrix";
    67         trainingConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    68         trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     63        trainingConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     64        trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    6965
    7066        ConfusionMatrixEvaluator validationConfusionMatrix = new ConfusionMatrixEvaluator();
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs

    r2130 r2161  
    3535namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3636  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm {
     37    public override IOperator ProblemInjector {
     38      get {
     39        CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
     40        return algo.OperatorGraph.InitialOperator.SubOperators[1];
     41      }
     42      set {
     43        CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
     44        algo.OperatorGraph.InitialOperator.RemoveSubOperator(1);
     45        value.Name = "ProblemInjector";
     46        algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1);
     47      }
     48    }
     49
    3750    protected override IOperator CreateFunctionLibraryInjector() {
    3851      return new FunctionLibraryInjector();
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs

    r2130 r2161  
    3535namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3636  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm {
     37    public override IOperator ProblemInjector {
     38      get {
     39        CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
     40        return algo.OperatorGraph.InitialOperator.SubOperators[1];
     41      }
     42      set {
     43        CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
     44        algo.OperatorGraph.InitialOperator.RemoveSubOperator(1);
     45        value.Name = "ProblemInjector";
     46        algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1);
     47      }
     48    }
     49   
    3750    protected override IOperator CreateFunctionLibraryInjector() {
    3851      return new FunctionLibraryInjector();
     
    6174        SequentialProcessor seq = new SequentialProcessor();
    6275        TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator();
    63         trainingTheil.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    64         trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     76        trainingTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     77        trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    6578        trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient";
    6679        trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias";
     
    6982
    7083        TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator();
    71         validationTheil.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    72         validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     84        validationTheil.GetVariableInfo("SamplesStart").ActualName = "ActualValidationSamplesStart";
     85        validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualValidationSamplesEnd";
    7386        validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient";
    7487        validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias";
     
    7790
    7891        TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator();
    79         testTheil.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    80         testTheil.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     92        testTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTestSamplesStart";
     93        testTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTestSamplesEnd";
    8194        testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient";
    8295        testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias";
     
    8598
    8699        SimpleEvaluator trainingEvaluator = new SimpleEvaluator();
    87         trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    88         trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     100        trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     101        trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    89102        trainingEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
    90103
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs

    r2057 r2161  
    6565
    6666    public virtual IOperator ProblemInjector {
    67       get { return algorithm.SubOperators[0]; }
     67      get { return algorithm.SubOperators[1]; }
    6868      set {
    6969        value.Name = "ProblemInjector";
    70         algorithm.RemoveSubOperator(0);
    71         algorithm.AddSubOperator(value, 0);
     70        algorithm.RemoveSubOperator(1);
     71        algorithm.AddSubOperator(value, 1);
    7272      }
    7373    }
     
    155155      MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
    156156      evaluator.GetVariableInfo("MSE").ActualName = "Quality";
    157       evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    158       evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     157      evaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     158      evaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    159159      evaluator.Name = "Evaluator";
    160160
     
    165165      LeftReducer cleanUp = new LeftReducer();
    166166
     167      seq.AddSubOperator(randomInjector);
    167168      seq.AddSubOperator(problemInjector);
    168       seq.AddSubOperator(randomInjector);
    169169      seq.AddSubOperator(globalInjector);
    170170      seq.AddSubOperator(funLibInjector);
     
    465465      // SequentialProcessor in GP
    466466      algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    467       return (RandomInjector)algorithm.SubOperators[1];
     467      return (RandomInjector)algorithm.SubOperators[0];
    468468    }
    469469
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs

    r2130 r2161  
    9696    }
    9797
     98    public override IOperator ProblemInjector {
     99      get { return base.ProblemInjector.SubOperators[0]; }
     100      set {
     101        value.Name = "ProblemInjector";
     102        base.ProblemInjector.RemoveSubOperator(0);
     103        base.ProblemInjector.AddSubOperator(value, 0);
     104      }
     105    }
     106
    98107    public StandardGP()
    99108      : base() {
     
    113122
    114123    protected internal override IOperator CreateProblemInjector() {
    115       return new ProblemInjector();
     124      SequentialProcessor seq = new SequentialProcessor();     
     125      var probInject = new ProblemInjector();
     126      probInject.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true;
     127      probInject.AddVariable(new HeuristicLab.Core.Variable("MaxNumberOfTrainingSamples", new IntData(5000)));
     128
     129      var shuffler = new DatasetShuffler();
     130      shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";
     131      shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";
     132
     133      seq.AddSubOperator(probInject);
     134      seq.AddSubOperator(shuffler);
     135      return seq;
    116136    }
    117137
     
    200220    protected internal override IOperator CreateBestSolutionProcessor() {
    201221      SequentialProcessor bestSolutionProcessor = new SequentialProcessor();
     222      #region MSE
    202223      MeanSquaredErrorEvaluator testMseEvaluator = new MeanSquaredErrorEvaluator();
    203224      testMseEvaluator.Name = "TestMeanSquaredErrorEvaluator";
     
    205226      testMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    206227      testMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     228      #endregion
     229      #region MAPE
    207230      MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
    208231      trainingMapeEvaluator.Name = "TrainingMapeEvaluator";
    209232      trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";
    210       trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    211       trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     233      trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     234      trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    212235      MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
    213236      validationMapeEvaluator.Name = "ValidationMapeEvaluator";
     
    220243      testMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    221244      testMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     245      #endregion
     246      #region MAPRE
    222247      MeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
    223248      trainingMapreEvaluator.Name = "TrainingMapreEvaluator";
    224249      trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE";
    225       trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    226       trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     250      trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     251      trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    227252      MeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
    228253      validationMapreEvaluator.Name = "ValidationMapreEvaluator";
     
    235260      testMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    236261      testMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     262      #endregion MAPRE
     263      #region R2
    237264      CoefficientOfDeterminationEvaluator trainingR2Evaluator = new CoefficientOfDeterminationEvaluator();
    238265      trainingR2Evaluator.Name = "TrainingR2Evaluator";
    239266      trainingR2Evaluator.GetVariableInfo("R2").ActualName = "TrainingR2";
    240       trainingR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    241       trainingR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     267      trainingR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     268      trainingR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    242269      CoefficientOfDeterminationEvaluator validationR2Evaluator = new CoefficientOfDeterminationEvaluator();
    243270      validationR2Evaluator.Name = "ValidationR2Evaluator";
     
    250277      testR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    251278      testR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     279      #endregion
     280      #region VAF
    252281      VarianceAccountedForEvaluator trainingVAFEvaluator = new VarianceAccountedForEvaluator();
    253282      trainingVAFEvaluator.Name = "TrainingVAFEvaluator";
    254283      trainingVAFEvaluator.GetVariableInfo("VAF").ActualName = "TrainingVAF";
    255       trainingVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    256       trainingVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     284      trainingVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     285      trainingVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    257286      VarianceAccountedForEvaluator validationVAFEvaluator = new VarianceAccountedForEvaluator();
    258287      validationVAFEvaluator.Name = "ValidationVAFEvaluator";
     
    265294      testVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    266295      testVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
    267 
     296      #endregion
    268297      ProgrammableOperator progOperator = new ProgrammableOperator();
    269298      progOperator.RemoveVariableInfo("Result");
  • trunk/sources/HeuristicLab.LinearRegression/3.2/HeuristicLab.LinearRegression-3.2.csproj

    r2154 r2161  
    133133      <Name>HeuristicLab.PluginInfrastructure</Name>
    134134    </ProjectReference>
     135    <ProjectReference Include="..\..\HeuristicLab.Random\3.2\HeuristicLab.Random-3.2.csproj">
     136      <Project>{47019A74-F7F7-482E-83AA-D3F4F777E879}</Project>
     137      <Name>HeuristicLab.Random-3.2</Name>
     138    </ProjectReference>
    135139    <ProjectReference Include="..\..\HeuristicLab.SequentialEngine\3.2\HeuristicLab.SequentialEngine-3.2.csproj">
    136140      <Project>{B4BE8E53-BA06-4237-9A01-24255F880201}</Project>
  • trunk/sources/HeuristicLab.LinearRegression/3.2/HeuristicLabLinearRegressionPlugin.cs

    r2155 r2161  
    3434  [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
    3535  [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
     36  [Dependency(Dependency = "HeuristicLab.Random-3.2")]
    3637  [Dependency(Dependency = "HeuristicLab.SequentialEngine-3.2")]
    3738  public class HeuristicLabLinearRegression : PluginBase {
  • trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs

    r2154 r2161  
    3333using HeuristicLab.Modeling;
    3434using HeuristicLab.GP;
     35using HeuristicLab.Random;
    3536
    3637namespace HeuristicLab.LinearRegression {
     
    8889      seq.Name = "LinearRegression";
    8990
     91      var randomInjector = new RandomInjector();
     92      randomInjector.Name = "Random Injector";
    9093      IOperator globalInjector = CreateGlobalInjector();
    9194      ProblemInjector problemInjector = new ProblemInjector();
     95      problemInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true;
     96      problemInjector.AddVariable(new HeuristicLab.Core.Variable("MaxNumberOfTrainingSamples", new IntData(5000)));
     97
     98      IOperator shuffler = new DatasetShuffler();
     99      shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";
     100      shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";
     101
    92102      LinearRegressionOperator lrOperator = new LinearRegressionOperator();
    93       lrOperator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    94       lrOperator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
    95 
    96 
     103      lrOperator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     104      lrOperator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
     105
     106      seq.AddSubOperator(randomInjector);
    97107      seq.AddSubOperator(globalInjector);
    98108      seq.AddSubOperator(problemInjector);
     109      seq.AddSubOperator(shuffler);
    99110      seq.AddSubOperator(lrOperator);
    100111      seq.AddSubOperator(CreateModelAnalyser());
    101 
    102112
    103113      algo.OperatorGraph.InitialOperator = seq;
     
    126136      trainingMSE.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel";
    127137      trainingMSE.GetVariableInfo("MSE").ActualName = "TrainingQuality";
    128       trainingMSE.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    129       trainingMSE.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     138      trainingMSE.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     139      trainingMSE.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    130140      MeanSquaredErrorEvaluator validationMSE = new MeanSquaredErrorEvaluator();
    131141      validationMSE.Name = "ValidationMseEvaluator";
     
    147157      trainingR2.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel";
    148158      trainingR2.GetVariableInfo("R2").ActualName = "TrainingR2";
    149       trainingR2.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    150       trainingR2.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     159      trainingR2.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     160      trainingR2.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    151161      CoefficientOfDeterminationEvaluator validationR2 = new CoefficientOfDeterminationEvaluator();
    152162      validationR2.Name = "ValidationR2Evaluator";
     
    168178      trainingMAPE.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel";
    169179      trainingMAPE.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";
    170       trainingMAPE.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    171       trainingMAPE.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     180      trainingMAPE.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     181      trainingMAPE.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    172182      MeanAbsolutePercentageErrorEvaluator validationMAPE = new MeanAbsolutePercentageErrorEvaluator();
    173183      validationMAPE.Name = "ValidationMapeEvaluator";
     
    189199      trainingMAPRE.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel";
    190200      trainingMAPRE.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE";
    191       trainingMAPRE.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    192       trainingMAPRE.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     201      trainingMAPRE.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     202      trainingMAPRE.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    193203      MeanAbsolutePercentageOfRangeErrorEvaluator validationMAPRE = new MeanAbsolutePercentageOfRangeErrorEvaluator();
    194204      validationMAPRE.Name = "ValidationMapreEvaluator";
     
    210220      trainingVAF.GetVariableInfo("FunctionTree").ActualName = "LinearRegressionModel";
    211221      trainingVAF.GetVariableInfo("VAF").ActualName = "TrainingVAF";
    212       trainingVAF.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    213       trainingVAF.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     222      trainingVAF.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     223      trainingVAF.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    214224      VarianceAccountedForEvaluator validationVAF = new VarianceAccountedForEvaluator();
    215225      validationVAF.Name = "ValidationVafEvaluator";
  • trunk/sources/HeuristicLab.Modeling/3.2/ProblemInjector.cs

    r1856 r2161  
    5656      AddVariable(new Variable("TrainingSamplesEnd", new IntData()));
    5757
     58      AddVariableInfo(new VariableInfo("ActualTrainingSamplesStart", "ActualTrainingSamplesStart", typeof(IntData), VariableKind.New));
     59      AddVariableInfo(new VariableInfo("ActualTrainingSamplesEnd", "ActualTrainingSamplesEnd", typeof(IntData), VariableKind.New));
     60
    5861      AddVariableInfo(new VariableInfo("ValidationSamplesStart", "ValidationSamplesStart", typeof(IntData), VariableKind.New));
    5962      GetVariableInfo("ValidationSamplesStart").Local = true;
     
    7174      GetVariableInfo("TestSamplesEnd").Local = true;
    7275      AddVariable(new Variable("TestSamplesEnd", new IntData()));
     76
     77      AddVariableInfo(new VariableInfo("MaxNumberOfTrainingSamples", "Maximal number of training samples to use (optional)", typeof(IntData), VariableKind.In));
    7378    }
    7479
     
    7883
    7984    public override IOperation Apply(IScope scope) {
    80       foreach(VariableInfo info in VariableInfos) {
    81         if(info.Local) {
    82           IVariable var = GetVariable(info.FormalName);
    83           if(var != null) scope.AddVariable(new Variable(info.ActualName, (IItem)var.Value.Clone()));
    84         }
     85      AddVariableToScope("Dataset", scope);
     86      AddVariableToScope("TargetVariable", scope);
     87      AddVariableToScope("AllowedFeatures", scope);
     88      AddVariableToScope("TrainingSamplesStart", scope);
     89      AddVariableToScope("TrainingSamplesEnd", scope);
     90      AddVariableToScope("ValidationSamplesStart", scope);
     91      AddVariableToScope("ValidationSamplesEnd", scope);
     92      AddVariableToScope("TestSamplesStart", scope);
     93      AddVariableToScope("TestSamplesEnd", scope);
     94
     95      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
     96      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     97
     98      var maxTraining = GetVariableValue<IntData>("MaxNumberOfTrainingSamples", scope, true, false);
     99      int nTrainingSamples;
     100      if (maxTraining != null) {
     101        nTrainingSamples = Math.Min(maxTraining.Data, trainingEnd - trainingStart);
     102        if (nTrainingSamples <= 0)
     103          throw new ArgumentException("Maximal number of training samples must be larger than 0", "MaxNumberOfTrainingSamples");
     104      } else {
     105        nTrainingSamples = trainingEnd - trainingStart;
    85106      }
     107      scope.AddVariable(new Variable(scope.TranslateName("ActualTrainingSamplesStart"), new IntData(trainingStart)));
     108      scope.AddVariable(new Variable(scope.TranslateName("ActualTrainingSamplesEnd"), new IntData(trainingStart + nTrainingSamples)));
    86109      return null;
     110    }
     111
     112    private void AddVariableToScope(string variableName, IScope scope) {
     113      scope.AddVariable(new Variable(variableName, (IItem)GetVariable(variableName).Value.Clone()));     
    87114    }
    88115  }
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs

    r2127 r2161  
    142142      seq.Name = "Initialization";
    143143      seq.AddSubOperator(CreateGlobalInjector());
    144       seq.AddSubOperator(new ProblemInjector());
     144      ProblemInjector probInjector = new ProblemInjector();
     145      probInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true;
     146      probInjector.AddVariable(new Variable("MaxNumberOfTrainingSamples", new IntData(5000)));
     147      seq.AddSubOperator(probInjector);
    145148      seq.AddSubOperator(new RandomInjector());
     149
     150      DatasetShuffler shuffler = new DatasetShuffler();
     151      shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";
     152      shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";
     153      seq.AddSubOperator(shuffler);
    146154      return seq;
    147155    }
     
    246254
    247255      SupportVectorCreator modelCreator = new SupportVectorCreator();
    248       modelCreator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
    249       modelCreator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     256      modelCreator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
     257      modelCreator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    250258      modelCreator.GetVariableInfo("SVMCost").ActualName = "Cost";
    251259      modelCreator.GetVariableInfo("SVMGamma").ActualName = "Gamma";
     
    256264
    257265      modelProcessor.AddSubOperator(modelCreator);
    258       CombinedOperator trainingEvaluator = (CombinedOperator)CreateEvaluator("Training");
     266      CombinedOperator trainingEvaluator = (CombinedOperator)CreateEvaluator("ActualTraining");
    259267      trainingEvaluator.OperatorGraph.InitialOperator.SubOperators[1].GetVariableInfo("MSE").ActualName = "Quality";
    260268      modelProcessor.AddSubOperator(trainingEvaluator);
     
    415423      model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data;
    416424      model.TestMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TestQuality", false).Data;
    417       model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data;
     425      model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingR2", false).Data;
    418426      model.ValidationCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data;
    419427      model.TestCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data;
    420       model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data;
     428      model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPE", false).Data;
    421429      model.ValidationMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data;
    422430      model.TestMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data;
    423       model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data;
     431      model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPRE", false).Data;
    424432      model.ValidationMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data;
    425433      model.TestMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data;
    426       model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data;
     434      model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingVAF", false).Data;
    427435      model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data;
    428436      model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
Note: See TracChangeset for help on using the changeset viewer.