#region License Information /* HeuristicLab * Copyright (C) 2002-2012 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 System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Algorithms.DataAnalysis; using HeuristicLab.Random; namespace HeuristicLab.Problems.Instances.DataAnalysis { public class GaussianProcessRegressionInstance1D : ArtificialRegressionDataDescriptor { private const int STEPS = 100; public override string Name { get { return "Gaussian Process " + name; } } public override string Description { get { return ""; } } protected override string TargetVariable { get { return "Y"; } } protected override string[] VariableNames { get { return new string[] { "X1","Y" }; } } protected override string[] AllowedInputVariables { get { return new string[] { "X1"}; } } protected override int TrainingPartitionStart { get { return 0; } } protected override int TrainingPartitionEnd { get { return (STEPS+1); } } protected override int TestPartitionStart { get { return TrainingPartitionEnd; } } protected override int TestPartitionEnd { get { return 2 * (STEPS + 1); } } private ParameterizedCovarianceFunction cov; private string name; public GaussianProcessRegressionInstance1D(string name, ICovarianceFunction covarianceFunction, double[] hyp) { this.name = name; cov = covarianceFunction.GetParameterizedCovarianceFunction(hyp, Enumerable.Range(0, 1)); } protected override List> GenerateValues() { List> trainingData = new List>() { ValueGenerator.GenerateSteps(0, 1, 1.0 / STEPS).ToList(), }; List> testData = new List>() { ValueGenerator.GenerateSteps(-0.1, 1.1, 1.2 / STEPS).ToList(), }; var trainingComb = ValueGenerator.GenerateAllCombinationsOfValuesInLists(trainingData).ToList>(); var testComb = ValueGenerator.GenerateAllCombinationsOfValuesInLists(testData).ToList>(); List> data = new List>(); for (int i = 0; i < AllowedInputVariables.Count(); i++) { data.Add(trainingComb[i].ToList()); data[i].AddRange(testComb[i]); } var mt = new MersenneTwister(); var target = Util.SampleGaussianProcess(mt, cov, data); data.Add(target); return data; } } }