Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/04/12 12:01:26 (12 years ago)
Author:
gkronber
Message:

#1902:

  • added caching for variances of GaussianProcessRegressionSolution.
  • changed hyperparameter initializers to generate initial values for hyperparameters in a larger range.
Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess
Files:
2 edited

Legend:

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

    r8463 r8732  
    9191      var rand = RandomParameter.ActualValue;
    9292      for (int i = 0; i < r.Length; i++)
    93         r[i] = rand.NextDouble() * 2 - 1;
     93        r[i] = rand.NextDouble() * 10 - 5;
    9494
    9595      HyperparameterParameter.ActualValue = r;
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs

    r8473 r8732  
    3434  [StorableClass]
    3535  public sealed class GaussianProcessRegressionSolution : RegressionSolution, IGaussianProcessSolution {
     36    private new readonly Dictionary<int, double> evaluationCache;
    3637
    3738    public new IGaussianProcessModel Model {
     
    4142
    4243    [StorableConstructor]
    43     private GaussianProcessRegressionSolution(bool deserializing) : base(deserializing) { }
     44    private GaussianProcessRegressionSolution(bool deserializing)
     45      : base(deserializing) {
     46      evaluationCache = new Dictionary<int, double>();
     47
     48    }
    4449    private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner)
    4550      : base(original, cloner) {
     51      evaluationCache = new Dictionary<int, double>(original.evaluationCache);
    4652    }
    4753    public GaussianProcessRegressionSolution(IGaussianProcessModel model, IRegressionProblemData problemData)
    4854      : base(model, problemData) {
     55
     56      evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows);
    4957      RecalculateResults();
    5058    }
     
    6573
    6674    public IEnumerable<double> GetEstimatedVariance(IEnumerable<int> rows) {
    67       return Model.GetEstimatedVariance(ProblemData.Dataset, rows);
     75      var rowsToEvaluate = rows.Except(evaluationCache.Keys);
     76      var rowsEnumerator = rowsToEvaluate.GetEnumerator();
     77      var valuesEnumerator = Model.GetEstimatedVariance(ProblemData.Dataset, rowsToEvaluate).GetEnumerator();
     78
     79      while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) {
     80        evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);
     81      }
     82
     83      return rows.Select(row => evaluationCache[row]);
     84    }
     85
     86    protected override void OnModelChanged() {
     87      evaluationCache.Clear();
     88      base.OnModelChanged();
     89    }
     90    protected override void OnProblemDataChanged() {
     91      evaluationCache.Clear();
     92      base.OnProblemDataChanged();
    6893    }
    6994  }
Note: See TracChangeset for help on using the changeset viewer.