#region License Information
/* HeuristicLab
* Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Encodings.RealVectorEncoding;
using HeuristicLab.Operators;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Algorithms.DataAnalysis {
[StorableClass("B80912A0-00F8-48FA-B7B1-3A63931C094D")]
// base class for GaussianProcessModelCreators (specific for classification and regression)
public abstract class GaussianProcessModelCreator : SingleSuccessorOperator {
private const string HyperparameterParameterName = "Hyperparameter";
private const string MeanFunctionParameterName = "MeanFunction";
private const string CovarianceFunctionParameterName = "CovarianceFunction";
private const string ModelParameterName = "Model";
private const string NegativeLogLikelihoodParameterName = "NegativeLogLikelihood";
private const string HyperparameterGradientsParameterName = "HyperparameterGradients";
protected const string ScaleInputValuesParameterName = "ScaleInputValues";
#region Parameter Properties
// in
public ILookupParameter HyperparameterParameter {
get { return (ILookupParameter)Parameters[HyperparameterParameterName]; }
}
public ILookupParameter MeanFunctionParameter {
get { return (ILookupParameter)Parameters[MeanFunctionParameterName]; }
}
public ILookupParameter CovarianceFunctionParameter {
get { return (ILookupParameter)Parameters[CovarianceFunctionParameterName]; }
}
// out
public ILookupParameter ModelParameter {
get { return (ILookupParameter)Parameters[ModelParameterName]; }
}
public ILookupParameter HyperparameterGradientsParameter {
get { return (ILookupParameter)Parameters[HyperparameterGradientsParameterName]; }
}
public ILookupParameter NegativeLogLikelihoodParameter {
get { return (ILookupParameter)Parameters[NegativeLogLikelihoodParameterName]; }
}
public ILookupParameter ScaleInputValuesParameter {
get { return (ILookupParameter)Parameters[ScaleInputValuesParameterName]; }
}
#endregion
#region Properties
protected RealVector Hyperparameter { get { return HyperparameterParameter.ActualValue; } }
protected IMeanFunction MeanFunction { get { return MeanFunctionParameter.ActualValue; } }
protected ICovarianceFunction CovarianceFunction { get { return CovarianceFunctionParameter.ActualValue; } }
public bool ScaleInputValues { get { return ScaleInputValuesParameter.ActualValue.Value; } }
#endregion
[StorableConstructor]
protected GaussianProcessModelCreator(bool deserializing) : base(deserializing) { }
protected GaussianProcessModelCreator(GaussianProcessModelCreator original, Cloner cloner) : base(original, cloner) { }
protected GaussianProcessModelCreator()
: base() {
// in
Parameters.Add(new LookupParameter(HyperparameterParameterName, "The hyperparameters for the Gaussian process model."));
Parameters.Add(new LookupParameter(MeanFunctionParameterName, "The mean function for the Gaussian process model."));
Parameters.Add(new LookupParameter(CovarianceFunctionParameterName, "The covariance function for the Gaussian process model."));
// out
Parameters.Add(new LookupParameter(ModelParameterName, "The resulting Gaussian process model"));
Parameters.Add(new LookupParameter(HyperparameterGradientsParameterName, "The gradients of the hyperparameters for the produced Gaussian process model (necessary for hyperparameter optimization)"));
Parameters.Add(new LookupParameter(NegativeLogLikelihoodParameterName, "The negative log-likelihood of the produced Gaussian process model given the data."));
Parameters.Add(new LookupParameter(ScaleInputValuesParameterName,
"Determines if the input variable values are scaled to the range [0..1] for training."));
Parameters[ScaleInputValuesParameterName].Hidden = true;
}
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
if (!Parameters.ContainsKey(ScaleInputValuesParameterName)) {
Parameters.Add(new LookupParameter(ScaleInputValuesParameterName,
"Determines if the input variable values are scaled to the range [0..1] for training."));
Parameters[ScaleInputValuesParameterName].Hidden = true;
}
}
}
}