Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModelCreator.cs @ 17578

Last change on this file since 17578 was 13118, checked in by gkronber, 9 years ago

#2497: added hidden parameter to turn on/off scaling of input variables in Gaussian process models

File size: 5.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Encodings.RealVectorEncoding;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Algorithms.DataAnalysis {
31  [StorableClass]
32  // base class for GaussianProcessModelCreators (specific for classification and regression)
33  public abstract class GaussianProcessModelCreator : SingleSuccessorOperator {
34    private const string HyperparameterParameterName = "Hyperparameter";
35    private const string MeanFunctionParameterName = "MeanFunction";
36    private const string CovarianceFunctionParameterName = "CovarianceFunction";
37    private const string ModelParameterName = "Model";
38    private const string NegativeLogLikelihoodParameterName = "NegativeLogLikelihood";
39    private const string HyperparameterGradientsParameterName = "HyperparameterGradients";
40    protected const string ScaleInputValuesParameterName = "ScaleInputValues";
41
42    #region Parameter Properties
43    // in
44    public ILookupParameter<RealVector> HyperparameterParameter {
45      get { return (ILookupParameter<RealVector>)Parameters[HyperparameterParameterName]; }
46    }
47    public ILookupParameter<IMeanFunction> MeanFunctionParameter {
48      get { return (ILookupParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }
49    }
50    public ILookupParameter<ICovarianceFunction> CovarianceFunctionParameter {
51      get { return (ILookupParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }
52    }
53    // out
54    public ILookupParameter<IGaussianProcessModel> ModelParameter {
55      get { return (ILookupParameter<IGaussianProcessModel>)Parameters[ModelParameterName]; }
56    }
57    public ILookupParameter<RealVector> HyperparameterGradientsParameter {
58      get { return (ILookupParameter<RealVector>)Parameters[HyperparameterGradientsParameterName]; }
59    }
60    public ILookupParameter<DoubleValue> NegativeLogLikelihoodParameter {
61      get { return (ILookupParameter<DoubleValue>)Parameters[NegativeLogLikelihoodParameterName]; }
62    }
63    public ILookupParameter<BoolValue> ScaleInputValuesParameter {
64      get { return (ILookupParameter<BoolValue>)Parameters[ScaleInputValuesParameterName]; }
65    }
66    #endregion
67
68    #region Properties
69    protected RealVector Hyperparameter { get { return HyperparameterParameter.ActualValue; } }
70    protected IMeanFunction MeanFunction { get { return MeanFunctionParameter.ActualValue; } }
71    protected ICovarianceFunction CovarianceFunction { get { return CovarianceFunctionParameter.ActualValue; } }
72    public bool ScaleInputValues { get { return ScaleInputValuesParameter.ActualValue.Value; } }
73    #endregion
74
75    [StorableConstructor]
76    protected GaussianProcessModelCreator(bool deserializing) : base(deserializing) { }
77    protected GaussianProcessModelCreator(GaussianProcessModelCreator original, Cloner cloner) : base(original, cloner) { }
78    protected GaussianProcessModelCreator()
79      : base() {
80      // in
81      Parameters.Add(new LookupParameter<RealVector>(HyperparameterParameterName, "The hyperparameters for the Gaussian process model."));
82      Parameters.Add(new LookupParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function for the Gaussian process model."));
83      Parameters.Add(new LookupParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function for the Gaussian process model."));
84      // out
85      Parameters.Add(new LookupParameter<IGaussianProcessModel>(ModelParameterName, "The resulting Gaussian process model"));
86      Parameters.Add(new LookupParameter<RealVector>(HyperparameterGradientsParameterName, "The gradients of the hyperparameters for the produced Gaussian process model (necessary for hyperparameter optimization)"));
87      Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogLikelihoodParameterName, "The negative log-likelihood of the produced Gaussian process model given the data."));
88
89
90      Parameters.Add(new LookupParameter<BoolValue>(ScaleInputValuesParameterName,
91        "Determines if the input variable values are scaled to the range [0..1] for training."));
92      Parameters[ScaleInputValuesParameterName].Hidden = true;
93    }
94
95    [StorableHook(HookType.AfterDeserialization)]
96    private void AfterDeserialization() {
97      if (!Parameters.ContainsKey(ScaleInputValuesParameterName)) {
98        Parameters.Add(new LookupParameter<BoolValue>(ScaleInputValuesParameterName,
99          "Determines if the input variable values are scaled to the range [0..1] for training."));
100        Parameters[ScaleInputValuesParameterName].Hidden = true;
101      }
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.