Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8371


Ignore:
Timestamp:
07/31/12 18:26:03 (12 years ago)
Author:
gkronber
Message:

#1902: worked on Gaussian Process algorithm

Location:
trunk/sources
Files:
7 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs

    r8366 r8371  
    44using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    55
    6 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     6namespace HeuristicLab.Algorithms.DataAnalysis {
    77  [StorableClass]
    88  [Item(Name = "CovarianceLinear", Description = "Linear covariance function with for Gaussian processes.")]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs

    r8323 r8371  
    55using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    66
    7 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     7namespace HeuristicLab.Algorithms.DataAnalysis {
    88  [StorableClass]
    99  [Item(Name = "CovarianceSEard", Description = "Squared exponential covariance function with automatic relevance determination for Gaussian processes.")]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEiso.cs

    r8323 r8371  
    55using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    66
    7 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     7namespace HeuristicLab.Algorithms.DataAnalysis {
    88  [StorableClass]
    99  [Item(Name = "CovarianceSEiso",
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs

    r8366 r8371  
    2828using HeuristicLab.Problems.DataAnalysis;
    2929
    30 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     30namespace HeuristicLab.Algorithms.DataAnalysis {
    3131  /// <summary>
    3232  /// Represents a Gaussian process model.
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs

    r8325 r8371  
    2121#endregion
    2222
     23using System;
    2324using System.Collections.Generic;
    2425using System.Linq;
     
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Data;
     30using HeuristicLab.Operators;
    2931using HeuristicLab.Optimization;
    3032using HeuristicLab.Parameters;
     
    3436using HeuristicLab.Random;
    3537
    36 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     38namespace HeuristicLab.Algorithms.DataAnalysis {
    3739  /// <summary>
    3840  ///Gaussian process regression data analysis algorithm.
     
    4143  [Creatable("Data Analysis")]
    4244  [StorableClass]
    43   public sealed class GaussianProcessRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> {
     45  public sealed class GaussianProcessRegression : EngineAlgorithm, IStorableContent {
     46    public string Filename { get; set; }
     47
     48    public override Type ProblemType { get { return typeof(IRegressionProblem); } }
     49    public new IRegressionProblem Problem {
     50      get { return (IRegressionProblem)base.Problem; }
     51      set { base.Problem = value; }
     52    }
     53
    4454    private const string MeanFunctionParameterName = "MeanFunction";
    4555    private const string CovarianceFunctionParameterName = "CovarianceFunction";
    46     private const string MinimizationIterationsParameterName = "MinimizationIterations";
    47     private const string NegativeLogLikelihoodTableParameterName = "NegativeLogLikelihoodTable";
    48     private const string HyperParametersTableParameterName = "HyperParametersTable";
     56    private const string MinimizationIterationsParameterName = "Iterations";
     57    //private const string NegativeLogLikelihoodTableParameterName = "NegativeLogLikelihoodTable";
     58    //private const string HyperParametersTableParameterName = "HyperParametersTable";
    4959
    5060    #region parameter properties
     
    95105      Parameters.Add(new ConstrainedValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.",
    96106        new ItemSet<ICovarianceFunction>(covFunctions), covFunctions.First()));
    97       Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization.", new IntValue(20)));
     107      Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with BFGS.", new IntValue(20)));
    98108      //Parameters.Add(new LookupParameter<DataTable>(NegativeLogLikelihoodTableParameterName, "The negative log likelihood values over the whole run."));
    99109      //Parameters.Add(new LookupParameter<DataTable>(HyperParametersTableParameterName, "The values of the hyper-parameters over the whole run."));
     110
     111      var setParameterLength = new GaussianProcessSetHyperparameterLength();
     112      var initializer = new BFGSInitializer();
     113      var makeStep = new BFGSMakeStep();
     114      var branch = new ConditionalBranch();
     115      var modelCreator = new GaussianProcessRegressionModelCreator();
     116      var updateResults = new BFGSUpdateResults();
     117
     118      OperatorGraph.InitialOperator = setParameterLength;
     119
     120      setParameterLength.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
     121      setParameterLength.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
     122      setParameterLength.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     123      setParameterLength.Successor = initializer;
     124
     125      initializer.IterationsParameter.ActualName = MinimizationIterationsParameterName;
     126      initializer.NumberOfHyperparameterParameter.ActualName = setParameterLength.NumberOfHyperparameterParameter.Name;
     127      initializer.Successor = makeStep;
     128
     129      makeStep.BFGSStateParameter.ActualName = initializer.BFGSStateParameter.Name;
     130      makeStep.HyperparameterParameter.ActualName = initializer.NumberOfHyperparameterParameter.Name;
     131      makeStep.Successor = branch;
     132
     133      branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name;
     134      branch.FalseBranch = modelCreator;
     135
     136      modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
     137      modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName;
     138      modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
     139      modelCreator.HyperparameterParameter.ActualName = initializer.HyperparameterParameter.Name;
     140      modelCreator.Successor = updateResults;
     141
     142      updateResults.BFGSStateParameter.ActualName = initializer.BFGSStateParameter.Name;
     143      updateResults.FunctionValueParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name;
     144      updateResults.HyperparameterGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name;
     145      updateResults.Successor = makeStep;
     146
    100147    }
    101148    [StorableHook(HookType.AfterDeserialization)]
     
    105152      return new GaussianProcessRegression(this, cloner);
    106153    }
    107 
     154    /*
    108155    #region Gaussian process regression
    109156    protected override void Run() {
     
    215262
    216263    #endregion
     264     */
    217265  }
    218266}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs

    r8323 r8371  
    2525using HeuristicLab.Problems.DataAnalysis;
    2626
    27 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     27namespace HeuristicLab.Algorithms.DataAnalysis {
    2828  /// <summary>
    2929  /// Represents a Gaussian process solution for a regression problem which can be visualized in the GUI.
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs

    r8323 r8371  
    33using HeuristicLab.Core;
    44
    5 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     5namespace HeuristicLab.Algorithms.DataAnalysis {
    66  public interface ICovarianceFunction : IItem {
    77    int GetNumberOfParameters(int numberOfVariables);
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs

    r8366 r8371  
    22using HeuristicLab.Core;
    33
    4 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     4namespace HeuristicLab.Algorithms.DataAnalysis {
    55  public interface IMeanFunction : IItem {
    66    int GetNumberOfParameters(int numberOfVariables);
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanConst.cs

    r8366 r8371  
    66using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    77
    8 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     8namespace HeuristicLab.Algorithms.DataAnalysis {
    99  [StorableClass]
    1010  [Item(Name = "MeanConst", Description = "Constant mean function for Gaussian processes.")]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanLinear.cs

    r8368 r8371  
    66using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    77
    8 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     8namespace HeuristicLab.Algorithms.DataAnalysis {
    99  [StorableClass]
    1010  [Item(Name = "MeanLinear", Description = "Linear mean function for Gaussian processes.")]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanZero.cs

    r8366 r8371  
    66using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    77
    8 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     8namespace HeuristicLab.Algorithms.DataAnalysis {
    99  [StorableClass]
    1010  [Item(Name = "MeanZero", Description = "Constant zero mean function for Gaussian processes.")]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs

    r8366 r8371  
    55using System.Linq;
    66
    7 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     7namespace HeuristicLab.Algorithms.DataAnalysis {
    88  public static class Util {
    99    public static double ScalarProd(IEnumerable<double> v, IEnumerable<double> u) {
     
    1717
    1818    public static double SqrDist(IEnumerable<double> x, IEnumerable<double> y) {
    19       return Math.Max(x.Zip(y, (a, b) => (a - b) * (a - b)).Sum(), 0);
     19      return x.Zip(y, SqrDist).Sum();
    2020    }
    2121
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r8366 r8371  
    122122    </Compile>
    123123    <Compile Include="FixedDataAnalysisAlgorithm.cs" />
     124    <Compile Include="GaussianProcess\BFGSInitializer.cs" />
     125    <Compile Include="GaussianProcess\BFGSState.cs" />
     126    <Compile Include="GaussianProcess\BFGSUpdateResults.cs" />
     127    <Compile Include="GaussianProcess\BFGSMakeStep.cs" />
     128    <Compile Include="GaussianProcess\GaussianProcessSetHyperparameterLength.cs" />
     129    <Compile Include="GaussianProcess\GaussianProcessRegressionModelCreator.cs" />
    124130    <Compile Include="GaussianProcess\CovarianceLinear.cs" />
     131    <Compile Include="GaussianProcess\GaussianProcessModelCreator.cs">
     132      <SubType>Code</SubType>
     133    </Compile>
    125134    <Compile Include="GaussianProcess\MeanLinear.cs" />
    126135    <Compile Include="GaussianProcess\Util.cs" />
     
    237246      <Private>False</Private>
    238247    </ProjectReference>
     248    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
     249      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
     250      <Name>HeuristicLab.Operators-3.3</Name>
     251    </ProjectReference>
     252    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     253      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     254      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     255    </ProjectReference>
    239256    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    240257      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessModel.cs

    r8323 r8371  
    2323using HeuristicLab.Problems.DataAnalysis;
    2424
    25 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     25namespace HeuristicLab.Algorithms.DataAnalysis {
    2626  /// <summary>
    2727  /// Interface to represent a Gaussian process posterior
     
    3232    ICovarianceFunction CovarianceFunction { get; }
    3333    IEnumerable<double> Hyperparameters { get; }
     34    double[] GetHyperparameterGradients();
    3435  }
    3536}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessSolution.cs

    r8323 r8371  
    2222using HeuristicLab.Problems.DataAnalysis;
    2323
    24 namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
     24namespace HeuristicLab.Algorithms.DataAnalysis {
    2525  /// <summary>
    2626  /// Interface to represent a Gaussian process solution (either regression or classification)
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame

    r8323 r8371  
    3737  [PluginDependency("HeuristicLab.Data", "3.3")]
    3838  [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
     39  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3940  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     41  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    4042  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4143  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Algorithms.ScatterSearch/3.3

    • Property svn:ignore
      •  

        old new  
        11*.user
        22Plugin.cs
         3obj
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.DayView/1.0

    • Property svn:ignore
      •  

        old new  
        33HeuristicLab.DayView-1.0.csproj.user
        44*.vs10x
         5*.user
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/2.4.1/ProtobufCS/src/ProtoGen

    • Property svn:ignore
      •  

        old new  
        11bin
        22obj
         3*.user
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/2.4.1/ProtobufCS/src/ProtocolBuffers

    • Property svn:ignore
      •  

        old new  
        11bin
        22obj
         3*.user
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/GaussianProcessRegressionTest.cs

    r8323 r8371  
    2525using System.Threading;
    2626using HeuristicLab.Algorithms.DataAnalysis;
    27 using HeuristicLab.Algorithms.DataAnalysis.GaussianProcess;
    2827using HeuristicLab.Common;
    2928using HeuristicLab.Core;
    3029using HeuristicLab.Problems.DataAnalysis;
     30using HeuristicLab.SequentialEngine;
    3131using Microsoft.VisualStudio.TestTools.UnitTesting;
    3232
     
    5959
    6060      var cv = new CrossValidation();
    61       cv.Algorithm = new GaussianProcessRegression();
     61      var alg = new GaussianProcessRegression();
     62      alg.Engine = new SequentialEngine();
     63      cv.Algorithm = alg;
     64
     65      cv.Problem = new RegressionProblem();
    6266      var rand = new HeuristicLab.Random.MersenneTwister();
    6367      double[,] data = GenerateData(100, rand);
     
    6569      Dataset ds = new Dataset(variables, data);
    6670      cv.Problem.ProblemDataParameter.ActualValue = new RegressionProblemData(ds, variables.Take(10), variables.Last());
     71      cv.Algorithm.Prepare();
    6772      cv.Folds.Value = 5;
    6873      cv.SamplesStart.Value = 0;
Note: See TracChangeset for help on using the changeset viewer.