Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/13 14:21:09 (12 years ago)
Author:
gkronber
Message:

#2000 created a base class for Gaussian process algorithms and implemented two specific versions for classification and regression with a parameter to choose the model creator

Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs

    r8623 r9096  
    2222
    2323using System;
     24using System.Linq;
    2425using HeuristicLab.Algorithms.GradientDescent;
    2526using HeuristicLab.Common;
     
    3031using HeuristicLab.Parameters;
    3132using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     33using HeuristicLab.PluginInfrastructure;
    3234using HeuristicLab.Problems.DataAnalysis;
    3335
     
    3941  [Creatable("Data Analysis")]
    4042  [StorableClass]
    41   public sealed class GaussianProcessClassification : EngineAlgorithm, IStorableContent {
     43  public sealed class GaussianProcessClassification : GaussianProcessBase, IStorableContent {
    4244    public string Filename { get; set; }
    4345
     
    4850    }
    4951
    50     private const string MeanFunctionParameterName = "MeanFunction";
    51     private const string CovarianceFunctionParameterName = "CovarianceFunction";
    52     private const string MinimizationIterationsParameterName = "Iterations";
    53     private const string ApproximateGradientsParameterName = "ApproximateGradients";
    54     private const string SeedParameterName = "Seed";
    55     private const string SetSeedRandomlyParameterName = "SetSeedRandomly";
     52    private const string ModelParameterName = "Model";
    5653
    5754    #region parameter properties
    58     public IValueParameter<IMeanFunction> MeanFunctionParameter {
    59       get { return (IValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }
     55    public IConstrainedValueParameter<IGaussianProcessClassificationModelCreator> ModelCreatorParameter {
     56      get { return (IConstrainedValueParameter<IGaussianProcessClassificationModelCreator>)Parameters[ModelCreatorParameterName]; }
    6057    }
    61     public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter {
    62       get { return (IValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }
     58    public IFixedValueParameter<GaussianProcessClassificationSolutionCreator> SolutionCreatorParameter {
     59      get { return (IFixedValueParameter<GaussianProcessClassificationSolutionCreator>)Parameters[SolutionCreatorParameterName]; }
    6360    }
    64     public IValueParameter<IntValue> MinimizationIterationsParameter {
    65       get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }
    66     }
    67     public IValueParameter<IntValue> SeedParameter {
    68       get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }
    69     }
    70     public IValueParameter<BoolValue> SetSeedRandomlyParameter {
    71       get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }
    72     }
    73     #endregion
    74     #region properties
    75     public IMeanFunction MeanFunction {
    76       set { MeanFunctionParameter.Value = value; }
    77       get { return MeanFunctionParameter.Value; }
    78     }
    79     public ICovarianceFunction CovarianceFunction {
    80       set { CovarianceFunctionParameter.Value = value; }
    81       get { return CovarianceFunctionParameter.Value; }
    82     }
    83     public int MinimizationIterations {
    84       set { MinimizationIterationsParameter.Value.Value = value; }
    85       get { return MinimizationIterationsParameter.Value.Value; }
    86     }
    87     public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }
    88     public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }
    8961    #endregion
    9062
     
    9365    private GaussianProcessClassification(GaussianProcessClassification original, Cloner cloner)
    9466      : base(original, cloner) {
     67      RegisterEventHandlers();
    9568    }
    9669    public GaussianProcessClassification()
    97       : base() {
     70      : base(new ClassificationProblem()) {
    9871      this.name = ItemName;
    9972      this.description = ItemDescription;
    10073
    101       Problem = new ClassificationProblem();
     74      var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessClassificationModelCreator>();
     75      var defaultModelCreator = modelCreators.First(c => c is GaussianProcessClassificationModelCreator);
    10276
    103       Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst()));
    104       Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSquaredExponentialIso()));
    105       Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20)));
    106       Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    107       Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
     77      // GP regression and classification algorithms only differ in the model and solution creators,
     78      // thus we use a common base class and use operator parameters to implement the specific versions.
     79      // Different model creators can be implemented,
     80      // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators
     81      Parameters.Add(new ConstrainedValueParameter<IGaussianProcessClassificationModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.",
     82        new ItemSet<IGaussianProcessClassificationModelCreator>(modelCreators), defaultModelCreator));
     83      // this parameter is not intended to be changed,
     84      Parameters.Add(new FixedValueParameter<GaussianProcessClassificationSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm",
     85        new GaussianProcessClassificationSolutionCreator()));
     86      Parameters[SolutionCreatorParameterName].Hidden = true;
    10887
    109       Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false)));
    110       Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed
    111 
    112       var randomCreator = new HeuristicLab.Random.RandomCreator();
    113       var gpInitializer = new GaussianProcessHyperparameterInitializer();
    114       var bfgsInitializer = new LbfgsInitializer();
    115       var makeStep = new LbfgsMakeStep();
    116       var branch = new ConditionalBranch();
    117       var modelCreator = new GaussianProcessClassificationModelCreator();
    118       var updateResults = new LbfgsUpdateResults();
    119       var analyzer = new LbfgsAnalyzer();
    120       var finalModelCreator = new GaussianProcessClassificationModelCreator();
    121       var finalAnalyzer = new LbfgsAnalyzer();
    122       var solutionCreator = new GaussianProcessClassificationSolutionCreator();
    123 
    124       OperatorGraph.InitialOperator = randomCreator;
    125       randomCreator.SeedParameter.ActualName = SeedParameterName;
    126       randomCreator.SeedParameter.Value = null;
    127       randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName;
    128       randomCreator.SetSeedRandomlyParameter.Value = null;
    129       randomCreator.Successor = gpInitializer;
    130 
    131       gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    132       gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    133       gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    134       gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    135       gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name;
    136       gpInitializer.Successor = bfgsInitializer;
    137 
    138       bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName;
    139       bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    140       bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName;
    141       bfgsInitializer.Successor = makeStep;
    142 
    143       makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    144       makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    145       makeStep.Successor = branch;
    146 
    147       branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name;
    148       branch.FalseBranch = modelCreator;
    149       branch.TrueBranch = finalModelCreator;
    150 
    151       modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    152       modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    153       modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    154       modelCreator.Successor = updateResults;
    155 
    156       updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    157       updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    158       updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    159       updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName;
    160       updateResults.Successor = analyzer;
    161 
    162       analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    163       analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    164       analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    165       analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    166       analyzer.PointsTableParameter.ActualName = "Hyperparameter table";
    167       analyzer.QualityGradientsTableParameter.ActualName = "Gradients table";
    168       analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table";
    169       analyzer.Successor = makeStep;
    170 
    171       finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    172       finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    173       finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    174       finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName;
    175       finalModelCreator.Successor = finalAnalyzer;
    176 
    177       finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    178       finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    179       finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    180       finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName;
    181       finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName;
    182       finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName;
    183       finalAnalyzer.Successor = solutionCreator;
    184 
    185       solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name;
    186       solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     88      ParameterizedModelCreators();
     89      ParameterizeSolutionCreator(SolutionCreatorParameter.Value);
     90      RegisterEventHandlers();
    18791    }
    18892
     93
    18994    [StorableHook(HookType.AfterDeserialization)]
    190     private void AfterDeserialization() { }
     95    private void AfterDeserialization() {
     96      RegisterEventHandlers();
     97    }
    19198
    19299    public override IDeepCloneable Clone(Cloner cloner) {
    193100      return new GaussianProcessClassification(this, cloner);
    194101    }
     102
     103    #region events
     104    private void RegisterEventHandlers() {
     105      ModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged;
     106    }
     107
     108    private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) {
     109      ParameterizedModelCreator(ModelCreatorParameter.Value);
     110    }
     111    #endregion
     112
     113    private void ParameterizedModelCreators() {
     114      foreach (var creator in ModelCreatorParameter.ValidValues) {
     115        ParameterizedModelCreator(creator);
     116      }
     117    }
     118
     119    private void ParameterizedModelCreator(IGaussianProcessClassificationModelCreator modelCreator) {
     120      modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     121      modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
     122      modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
     123
     124      // parameter names fixed by the algorithm
     125      modelCreator.ModelParameter.ActualName = ModelParameterName;
     126      modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName;
     127      modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName;
     128      modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName;
     129    }
     130
     131    private void ParameterizeSolutionCreator(GaussianProcessClassificationSolutionCreator solutionCreator) {
     132      solutionCreator.ModelParameter.ActualName = ModelParameterName;
     133      solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     134    }
    195135  }
    196136}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationModelCreator.cs

    r8623 r9096  
    3434  [Item(Name = "GaussianProcessClassificationModelCreator",
    3535    Description = "Creates a Gaussian process model for least-squares classification given the data, the hyperparameters, a mean function, and a covariance function.")]
    36   public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator {
     36  public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator, IGaussianProcessClassificationModelCreator {
    3737    private const string ProblemDataParameterName = "ProblemData";
    3838
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs

    r8615 r9096  
    2222
    2323using System;
     24using System.Linq;
    2425using HeuristicLab.Algorithms.GradientDescent;
    2526using HeuristicLab.Common;
     
    3031using HeuristicLab.Parameters;
    3132using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     33using HeuristicLab.PluginInfrastructure;
    3234using HeuristicLab.Problems.DataAnalysis;
    3335
     
    3941  [Creatable("Data Analysis")]
    4042  [StorableClass]
    41   public sealed class GaussianProcessRegression : EngineAlgorithm, IStorableContent {
     43  public sealed class GaussianProcessRegression : GaussianProcessBase, IStorableContent {
    4244    public string Filename { get; set; }
    4345
     
    4850    }
    4951
    50     private const string MeanFunctionParameterName = "MeanFunction";
    51     private const string CovarianceFunctionParameterName = "CovarianceFunction";
    52     private const string MinimizationIterationsParameterName = "Iterations";
    53     private const string ApproximateGradientsParameterName = "ApproximateGradients";
    54     private const string SeedParameterName = "Seed";
    55     private const string SetSeedRandomlyParameterName = "SetSeedRandomly";
     52    private const string ModelParameterName = "Model";
    5653
    5754    #region parameter properties
    58     public IValueParameter<IMeanFunction> MeanFunctionParameter {
    59       get { return (IValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }
     55    public IConstrainedValueParameter<IGaussianProcessRegressionModelCreator> ModelCreatorParameter {
     56      get { return (IConstrainedValueParameter<IGaussianProcessRegressionModelCreator>)Parameters[ModelCreatorParameterName]; }
    6057    }
    61     public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter {
    62       get { return (IValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }
     58    public IFixedValueParameter<GaussianProcessRegressionSolutionCreator> SolutionCreatorParameter {
     59      get { return (IFixedValueParameter<GaussianProcessRegressionSolutionCreator>)Parameters[SolutionCreatorParameterName]; }
    6360    }
    64     public IValueParameter<IntValue> MinimizationIterationsParameter {
    65       get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }
    66     }
    67     public IValueParameter<IntValue> SeedParameter {
    68       get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }
    69     }
    70     public IValueParameter<BoolValue> SetSeedRandomlyParameter {
    71       get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }
    72     }
    73     #endregion
    74     #region properties
    75     public IMeanFunction MeanFunction {
    76       set { MeanFunctionParameter.Value = value; }
    77       get { return MeanFunctionParameter.Value; }
    78     }
    79     public ICovarianceFunction CovarianceFunction {
    80       set { CovarianceFunctionParameter.Value = value; }
    81       get { return CovarianceFunctionParameter.Value; }
    82     }
    83     public int MinimizationIterations {
    84       set { MinimizationIterationsParameter.Value.Value = value; }
    85       get { return MinimizationIterationsParameter.Value.Value; }
    86     }
    87     public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }
    88     public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }
    8961    #endregion
    9062
     
    9365    private GaussianProcessRegression(GaussianProcessRegression original, Cloner cloner)
    9466      : base(original, cloner) {
     67      RegisterEventHandlers();
    9568    }
    9669    public GaussianProcessRegression()
    97       : base() {
     70      : base(new RegressionProblem()) {
    9871      this.name = ItemName;
    9972      this.description = ItemDescription;
    10073
    101       Problem = new RegressionProblem();
     74      var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessRegressionModelCreator>();
     75      var defaultModelCreator = modelCreators.First(c => c is GaussianProcessRegressionModelCreator);
    10276
    103       Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst()));
    104       Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSquaredExponentialIso()));
    105       Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20)));
    106       Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    107       Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
     77      // GP regression and classification algorithms only differ in the model and solution creators,
     78      // thus we use a common base class and use operator parameters to implement the specific versions.
     79      // Different model creators can be implemented,
     80      // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators
     81      Parameters.Add(new ConstrainedValueParameter<IGaussianProcessRegressionModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.",
     82        new ItemSet<IGaussianProcessRegressionModelCreator>(modelCreators), defaultModelCreator));
     83      // this parameter is not intended to be changed,
     84      Parameters.Add(new FixedValueParameter<GaussianProcessRegressionSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm",
     85        new GaussianProcessRegressionSolutionCreator()));
     86      Parameters[SolutionCreatorParameterName].Hidden = true;
    10887
    109       Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false)));
    110       Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed
    111 
    112       var randomCreator = new HeuristicLab.Random.RandomCreator();
    113       var gpInitializer = new GaussianProcessHyperparameterInitializer();
    114       var bfgsInitializer = new LbfgsInitializer();
    115       var makeStep = new LbfgsMakeStep();
    116       var branch = new ConditionalBranch();
    117       var modelCreator = new GaussianProcessRegressionModelCreator();
    118       var updateResults = new LbfgsUpdateResults();
    119       var analyzer = new LbfgsAnalyzer();
    120       var finalModelCreator = new GaussianProcessRegressionModelCreator();
    121       var finalAnalyzer = new LbfgsAnalyzer();
    122       var solutionCreator = new GaussianProcessRegressionSolutionCreator();
    123 
    124       OperatorGraph.InitialOperator = randomCreator;
    125       randomCreator.SeedParameter.ActualName = SeedParameterName;
    126       randomCreator.SeedParameter.Value = null;
    127       randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName;
    128       randomCreator.SetSeedRandomlyParameter.Value = null;
    129       randomCreator.Successor = gpInitializer;
    130 
    131       gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    132       gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    133       gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    134       gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    135       gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name;
    136       gpInitializer.Successor = bfgsInitializer;
    137 
    138       bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName;
    139       bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    140       bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName;
    141       bfgsInitializer.Successor = makeStep;
    142 
    143       makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    144       makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    145       makeStep.Successor = branch;
    146 
    147       branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name;
    148       branch.FalseBranch = modelCreator;
    149       branch.TrueBranch = finalModelCreator;
    150 
    151       modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    152       modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    153       modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    154       modelCreator.Successor = updateResults;
    155 
    156       updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    157       updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    158       updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    159       updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName;
    160       updateResults.Successor = analyzer;
    161 
    162       analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    163       analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    164       analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    165       analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name;
    166       analyzer.PointsTableParameter.ActualName = "Hyperparameter table";
    167       analyzer.QualityGradientsTableParameter.ActualName = "Gradients table";
    168       analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table";
    169       analyzer.Successor = makeStep;
    170 
    171       finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    172       finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
    173       finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
    174       finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName;
    175       finalModelCreator.Successor = finalAnalyzer;
    176 
    177       finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
    178       finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name;
    179       finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
    180       finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName;
    181       finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName;
    182       finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName;
    183       finalAnalyzer.Successor = solutionCreator;
    184 
    185       solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name;
    186       solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     88      ParameterizedModelCreators();
     89      ParameterizeSolutionCreator(SolutionCreatorParameter.Value);
     90      RegisterEventHandlers();
    18791    }
    18892
     93
    18994    [StorableHook(HookType.AfterDeserialization)]
    190     private void AfterDeserialization() { }
     95    private void AfterDeserialization() {
     96      RegisterEventHandlers();
     97    }
    19198
    19299    public override IDeepCloneable Clone(Cloner cloner) {
    193100      return new GaussianProcessRegression(this, cloner);
    194101    }
     102
     103    #region events
     104    private void RegisterEventHandlers() {
     105      ModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged;
     106    }
     107
     108    private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) {
     109      ParameterizedModelCreator(ModelCreatorParameter.Value);
     110    }
     111    #endregion
     112
     113    private void ParameterizedModelCreators() {
     114      foreach (var creator in ModelCreatorParameter.ValidValues) {
     115        ParameterizedModelCreator(creator);
     116      }
     117    }
     118
     119    private void ParameterizedModelCreator(IGaussianProcessRegressionModelCreator modelCreator) {
     120      modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     121      modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
     122      modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
     123
     124      // parameter names fixed by the algorithm
     125      modelCreator.ModelParameter.ActualName = ModelParameterName;
     126      modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName;
     127      modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName;
     128      modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName;
     129    }
     130
     131    private void ParameterizeSolutionCreator(GaussianProcessRegressionSolutionCreator solutionCreator) {
     132      solutionCreator.ModelParameter.ActualName = ModelParameterName;
     133      solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     134    }
    195135  }
    196136}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs

    r8484 r9096  
    3434  [Item(Name = "GaussianProcessRegressionModelCreator",
    3535    Description = "Creates a Gaussian process model for regression given the data, the hyperparameters, a mean function, and a covariance function.")]
    36   public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator {
     36  public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator, IGaussianProcessRegressionModelCreator {
    3737    private const string ProblemDataParameterName = "ProblemData";
    3838
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r8982 r9096  
    120120    </Compile>
    121121    <Compile Include="FixedDataAnalysisAlgorithm.cs" />
     122    <Compile Include="GaussianProcess\GaussianProcessBase.cs" />
    122123    <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceConst.cs">
    123124      <SubType>Code</SubType>
     
    184185    <Compile Include="GaussianProcess\GaussianProcessRegressionSolution.cs" />
    185186    <Compile Include="GaussianProcess\ICovarianceFunction.cs" />
     187    <Compile Include="Interfaces\IGaussianProcessClassificationModelCreator.cs" />
     188    <Compile Include="Interfaces\IGaussianProcessRegressionModelCreator.cs" />
     189    <Compile Include="Interfaces\IGaussianProcessModelCreator.cs" />
    186190    <Compile Include="Interfaces\IGaussianProcessModel.cs" />
    187191    <Compile Include="Interfaces\IGaussianProcessSolution.cs" />
Note: See TracChangeset for help on using the changeset viewer.