Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8733


Ignore:
Timestamp:
10/04/12 12:56:28 (12 years ago)
Author:
gkronber
Message:

#1902: added a unit test to create and run a GPR sample

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/SamplesTest.cs

    r8667 r8733  
    2323using System.Linq;
    2424using System.Threading;
     25using HeuristicLab.Algorithms.DataAnalysis;
    2526using HeuristicLab.Algorithms.EvolutionStrategy;
    2627using HeuristicLab.Algorithms.GeneticAlgorithm;
     
    910911    #endregion
    911912
     913
     914    #region Gaussian Process Regression
     915    [TestMethod]
     916    public void CreateGaussianProcessRegressionSampleTest() {
     917      var vns = CreateGaussianProcessRegressionSample();
     918      XmlGenerator.Serialize(vns, "../../GaussianProcessRegression.hl");
     919    }
     920    [TestMethod]
     921    public void RunGaussianProcessRegressionSample() {
     922      var gpr = CreateGaussianProcessRegressionSample();
     923      gpr.SetSeedRandomly = false;
     924      gpr.Seed = 1618551877;
     925      RunAlgorithm(gpr);
     926      Assert.AreEqual(-940.48768748097029, GetDoubleResult(gpr, "NegativeLogLikelihood"));
     927      Assert.AreEqual(0.99561947047986976, GetDoubleResult(gpr, "Training R²"));
     928      Assert.AreEqual(0.99564766805508775, GetDoubleResult(gpr, "Test R²"));
     929    }
     930
     931    private GaussianProcessRegression CreateGaussianProcessRegressionSample() {
     932      var gpr = new GaussianProcessRegression();
     933      var provider = new VariousInstanceProvider();
     934      var instance = provider.GetDataDescriptors().Where(x => x.Name.Contains("Spatial co-evolution")).Single();
     935      var regProblem = new RegressionProblem();
     936      regProblem.Load(provider.LoadData(instance));
     937      #region Algorithm Configuration
     938      gpr.Name = "Gaussian Process Regression";
     939      gpr.Description = "A Gaussian process regression algorithm applied to the spatial co-evolution benchmark problem.";
     940      gpr.Problem = regProblem;
     941
     942      gpr.CovarianceFunction = new CovarianceSquaredExponentialIso();
     943      gpr.MeanFunction = new MeanConst();
     944      gpr.MinimizationIterations = 20;
     945      gpr.Seed = 0;
     946      gpr.SetSeedRandomly = true;
     947      #endregion
     948      gpr.Engine = new ParallelEngine();
     949      return gpr;
     950    }
     951    #endregion
     952
    912953    #region Helpers
    913954    private void ConfigureEvolutionStrategyParameters<R, M, SC, SR, SM>(EvolutionStrategy es, int popSize, int children, int parentsPerChild, int maxGens, bool plusSelection)
Note: See TracChangeset for help on using the changeset viewer.