- Timestamp:
- 07/10/17 19:19:26 (7 years ago)
- Location:
- stable
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 14899,14918,15160,15163,15165,15187
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 14899,14918,15160,15163,15165,15187
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs
r15143 r15188 46 46 47 47 [Storable] 48 private double loocvNegLogPseudoLikelihood; 49 public double LooCvNegativeLogPseudoLikelihood { 50 get { return loocvNegLogPseudoLikelihood; } 51 } 52 53 [Storable] 48 54 private double[] hyperparameterGradients; 49 55 public double[] HyperparameterGradients { … … 128 134 this.trainingDataset = cloner.Clone(original.trainingDataset); 129 135 this.negativeLogLikelihood = original.negativeLogLikelihood; 136 this.loocvNegLogPseudoLikelihood = original.loocvNegLogPseudoLikelihood; 130 137 this.sqrSigmaNoise = original.sqrSigmaNoise; 131 138 if (original.meanParameter != null) { … … 217 224 alglib.spdmatrixcholeskyinverse(ref lCopy, n, false, out info, out matInvRep); 218 225 if (info != 1) throw new ArgumentException("Can't invert matrix to calculate gradients."); 226 227 // LOOCV log pseudo-likelihood (or log predictive probability) (GPML page 116 and 117) 228 var sumLoo = 0.0; 229 var ki = new double[n]; 230 for (int i = 0; i < n; i++) { 231 for (int j = 0; j < n; j++) ki[j] = cov.Covariance(x, i, j); 232 ki[i] += sqrSigmaNoise; 233 234 var yi = Util.ScalarProd(ki, alpha); 235 var yi_loo = yi - alpha[i] / (lCopy[i, i] / sqrSigmaNoise); 236 var s2_loo = 1.0 / (lCopy[i, i] / sqrSigmaNoise); 237 var err = ym[i] - yi_loo; 238 var nll_loo = 0.5 * Math.Log(2 * Math.PI * s2_loo) + 0.5 * err * err / s2_loo; 239 sumLoo += nll_loo; 240 } 241 loocvNegLogPseudoLikelihood = sumLoo; 242 219 243 for (int i = 0; i < n; i++) { 220 244 for (int j = 0; j <= i; j++) -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModelCreator.cs
r14186 r15188 37 37 private const string ModelParameterName = "Model"; 38 38 private const string NegativeLogLikelihoodParameterName = "NegativeLogLikelihood"; 39 private const string NegativeLogPseudoLikelihoodParameterName = "NegativeLogPseudoLikelihood (LOOCV)"; 39 40 private const string HyperparameterGradientsParameterName = "HyperparameterGradients"; 40 41 protected const string ScaleInputValuesParameterName = "ScaleInputValues"; … … 60 61 public ILookupParameter<DoubleValue> NegativeLogLikelihoodParameter { 61 62 get { return (ILookupParameter<DoubleValue>)Parameters[NegativeLogLikelihoodParameterName]; } 63 } 64 public ILookupParameter<DoubleValue> NegativeLogPseudoLikelihoodParameter { 65 get { return (ILookupParameter<DoubleValue>)Parameters[NegativeLogPseudoLikelihoodParameterName]; } 62 66 } 63 67 public ILookupParameter<BoolValue> ScaleInputValuesParameter { … … 86 90 Parameters.Add(new LookupParameter<RealVector>(HyperparameterGradientsParameterName, "The gradients of the hyperparameters for the produced Gaussian process model (necessary for hyperparameter optimization)")); 87 91 Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogLikelihoodParameterName, "The negative log-likelihood of the produced Gaussian process model given the data.")); 92 Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogPseudoLikelihoodParameterName, "The leave-one-out-cross-validation negative log pseudo-likelihood of the produced Gaussian process model given the data.")); 88 93 89 94 … … 100 105 Parameters[ScaleInputValuesParameterName].Hidden = true; 101 106 } 107 if (!Parameters.ContainsKey(NegativeLogPseudoLikelihoodParameterName)) { 108 Parameters.Add(new LookupParameter<DoubleValue>(NegativeLogPseudoLikelihoodParameterName, 109 "The leave-one-out-cross-validation negative log pseudo-likelihood of the produced Gaussian process model given the data.")); 110 } 102 111 } 103 112 } -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs
r14186 r15188 65 65 ModelParameter.ActualValue = model; 66 66 NegativeLogLikelihoodParameter.ActualValue = new DoubleValue(model.NegativeLogLikelihood); 67 NegativeLogPseudoLikelihoodParameter.ActualValue = new DoubleValue(model.LooCvNegativeLogPseudoLikelihood); 67 68 HyperparameterGradientsParameter.ActualValue = new RealVector(model.HyperparameterGradients); 68 69 return base.Apply(); -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs
r14186 r15188 41 41 private const string TestRSquaredResultName = "Test R²"; 42 42 private const string CreateSolutionParameterName = "CreateSolution"; 43 private const string NegLogPseudoLikelihood = "Negative log pseudo-likelihood (LOO-CV)"; 43 44 44 45 #region Parameter Properties … … 108 109 "The Pearson's R² of the Gaussian process solution on the test partition.", 109 110 new DoubleValue(s.TestRSquared))); 111 results.Add(new Result(NegLogPseudoLikelihood, 112 "The negative log pseudo-likelihood (from leave-one-out-cross-validation).", 113 new DoubleValue(m.LooCvNegativeLogPseudoLikelihood))); 110 114 } else { 111 115 results[SolutionParameterName].Value = s; 112 116 results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared); 113 117 results[TestRSquaredResultName].Value = new DoubleValue(s.TestRSquared); 118 results[NegLogPseudoLikelihood].Value = new DoubleValue(m.LooCvNegativeLogPseudoLikelihood); 114 119 } 115 120 }
Note: See TracChangeset
for help on using the changeset viewer.