[8371] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8371] | 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 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
[8396] | 25 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
[8371] | 26 | using HeuristicLab.Operators;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 |
|
---|
| 30 | namespace 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";
|
---|
[15187] | 39 | private const string NegativeLogPseudoLikelihoodParameterName = "NegativeLogPseudoLikelihood (LOOCV)";
|
---|
[8371] | 40 | private const string HyperparameterGradientsParameterName = "HyperparameterGradients";
|
---|
[13118] | 41 | protected const string ScaleInputValuesParameterName = "ScaleInputValues";
|
---|
[8371] | 42 |
|
---|
| 43 | #region Parameter Properties
|
---|
| 44 | // in
|
---|
[8396] | 45 | public ILookupParameter<RealVector> HyperparameterParameter {
|
---|
| 46 | get { return (ILookupParameter<RealVector>)Parameters[HyperparameterParameterName]; }
|
---|
[8371] | 47 | }
|
---|
| 48 | public ILookupParameter<IMeanFunction> MeanFunctionParameter {
|
---|
| 49 | get { return (ILookupParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }
|
---|
| 50 | }
|
---|
| 51 | public ILookupParameter<ICovarianceFunction> CovarianceFunctionParameter {
|
---|
| 52 | get { return (ILookupParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }
|
---|
| 53 | }
|
---|
| 54 | // out
|
---|
| 55 | public ILookupParameter<IGaussianProcessModel> ModelParameter {
|
---|
| 56 | get { return (ILookupParameter<IGaussianProcessModel>)Parameters[ModelParameterName]; }
|
---|
| 57 | }
|
---|
[8396] | 58 | public ILookupParameter<RealVector> HyperparameterGradientsParameter {
|
---|
| 59 | get { return (ILookupParameter<RealVector>)Parameters[HyperparameterGradientsParameterName]; }
|
---|
[8371] | 60 | }
|
---|
| 61 | public ILookupParameter<DoubleValue> NegativeLogLikelihoodParameter {
|
---|
| 62 | get { return (ILookupParameter<DoubleValue>)Parameters[NegativeLogLikelihoodParameterName]; }
|
---|
| 63 | }
|
---|
[15187] | 64 | public ILookupParameter<DoubleValue> NegativeLogPseudoLikelihoodParameter {
|
---|
| 65 | get { return (ILookupParameter<DoubleValue>)Parameters[NegativeLogPseudoLikelihoodParameterName]; }
|
---|
[14899] | 66 | }
|
---|
[13118] | 67 | public ILookupParameter<BoolValue> ScaleInputValuesParameter {
|
---|
| 68 | get { return (ILookupParameter<BoolValue>)Parameters[ScaleInputValuesParameterName]; }
|
---|
| 69 | }
|
---|
[8371] | 70 | #endregion
|
---|
| 71 |
|
---|
| 72 | #region Properties
|
---|
[8396] | 73 | protected RealVector Hyperparameter { get { return HyperparameterParameter.ActualValue; } }
|
---|
[8375] | 74 | protected IMeanFunction MeanFunction { get { return MeanFunctionParameter.ActualValue; } }
|
---|
| 75 | protected ICovarianceFunction CovarianceFunction { get { return CovarianceFunctionParameter.ActualValue; } }
|
---|
[13118] | 76 | public bool ScaleInputValues { get { return ScaleInputValuesParameter.ActualValue.Value; } }
|
---|
[8371] | 77 | #endregion
|
---|
| 78 |
|
---|
| 79 | [StorableConstructor]
|
---|
| 80 | protected GaussianProcessModelCreator(bool deserializing) : base(deserializing) { }
|
---|
| 81 | protected GaussianProcessModelCreator(GaussianProcessModelCreator original, Cloner cloner) : base(original, cloner) { }
|
---|
| 82 | protected GaussianProcessModelCreator()
|
---|
| 83 | : base() {
|
---|
| 84 | // in
|
---|
[8396] | 85 | Parameters.Add(new LookupParameter<RealVector>(HyperparameterParameterName, "The hyperparameters for the Gaussian process model."));
|
---|
[8371] | 86 | Parameters.Add(new LookupParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function for the Gaussian process model."));
|
---|
| 87 | Parameters.Add(new LookupParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function for the Gaussian process model."));
|
---|
| 88 | // out
|
---|
| 89 | Parameters.Add(new LookupParameter<IGaussianProcessModel>(ModelParameterName, "The resulting Gaussian process model"));
|
---|
[8396] | 90 | Parameters.Add(new LookupParameter<RealVector>(HyperparameterGradientsParameterName, "The gradients of the hyperparameters for the produced Gaussian process model (necessary for hyperparameter optimization)"));
|
---|
[8371] | 91 | Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogLikelihoodParameterName, "The negative log-likelihood of the produced Gaussian process model given the data."));
|
---|
[15187] | 92 | Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogPseudoLikelihoodParameterName, "The leave-one-out-cross-validation negative log pseudo-likelihood of the produced Gaussian process model given the data."));
|
---|
[13118] | 93 |
|
---|
| 94 |
|
---|
| 95 | Parameters.Add(new LookupParameter<BoolValue>(ScaleInputValuesParameterName,
|
---|
| 96 | "Determines if the input variable values are scaled to the range [0..1] for training."));
|
---|
| 97 | Parameters[ScaleInputValuesParameterName].Hidden = true;
|
---|
[8371] | 98 | }
|
---|
[13118] | 99 |
|
---|
| 100 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 101 | private void AfterDeserialization() {
|
---|
| 102 | if (!Parameters.ContainsKey(ScaleInputValuesParameterName)) {
|
---|
| 103 | Parameters.Add(new LookupParameter<BoolValue>(ScaleInputValuesParameterName,
|
---|
| 104 | "Determines if the input variable values are scaled to the range [0..1] for training."));
|
---|
| 105 | Parameters[ScaleInputValuesParameterName].Hidden = true;
|
---|
| 106 | }
|
---|
[15187] | 107 | if (!Parameters.ContainsKey(NegativeLogPseudoLikelihoodParameterName)) {
|
---|
| 108 | Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogPseudoLikelihoodParameterName,
|
---|
| 109 | "The leave-one-out-cross-validation negative log pseudo-likelihood of the produced Gaussian process model given the data."));
|
---|
[14899] | 110 | }
|
---|
[13118] | 111 | }
|
---|
[8371] | 112 | }
|
---|
| 113 | }
|
---|