Ejemplo n.º 1
0
        public override IOperation Apply()
        {
            if (ModelParameter.ActualValue != null && CreateSolutionParameter.ActualValue.Value == true)
            {
                var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone();
                m.FixParameters();
                var data = (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone();
                var s    = new GaussianProcessRegressionSolution(m, data);


                SolutionParameter.ActualValue = s;
                var results = ResultsParameter.ActualValue;
                if (!results.ContainsKey(SolutionParameterName))
                {
                    results.Add(new Result(SolutionParameterName, "The Gaussian process regression solution", s));
                    results.Add(new Result(TrainingRSquaredResultName,
                                           "The Pearson's R² of the Gaussian process solution on the training partition.",
                                           new DoubleValue(s.TrainingRSquared)));
                    results.Add(new Result(TestRSquaredResultName,
                                           "The Pearson's R² of the Gaussian process solution on the test partition.",
                                           new DoubleValue(s.TestRSquared)));
                    results.Add(new Result(NegLogPseudoLikelihood,
                                           "The negative log pseudo-likelihood (from leave-one-out-cross-validation).",
                                           new DoubleValue(m.LooCvNegativeLogPseudoLikelihood)));
                }
                else
                {
                    results[SolutionParameterName].Value      = s;
                    results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared);
                    results[TestRSquaredResultName].Value     = new DoubleValue(s.TestRSquared);
                    results[NegLogPseudoLikelihood].Value     = new DoubleValue(m.LooCvNegativeLogPseudoLikelihood);
                }
            }
            return(base.Apply());
        }
Ejemplo n.º 2
0
        public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters)
        {
            if (pd.Dataset.Rows < MinLeafSize(pd))
            {
                throw new ArgumentException("The number of training instances is too small to create a Gaussian process model");
            }
            Regression.Problem = new RegressionProblem {
                ProblemData = pd
            };
            var cvscore = double.MaxValue;
            GaussianProcessRegressionSolution sol = null;

            for (var i = 0; i < Tries; i++)
            {
                var res   = RegressionTreeUtilities.RunSubAlgorithm(Regression, random.Next(), cancellationToken);
                var t     = res.Select(x => x.Value).OfType <GaussianProcessRegressionSolution>().FirstOrDefault();
                var score = ((DoubleValue)res["Negative log pseudo-likelihood (LOO-CV)"].Value).Value;
                if (score >= cvscore || t == null || double.IsNaN(t.TrainingRSquared))
                {
                    continue;
                }
                cvscore = score;
                sol     = t;
            }
            Regression.Runs.Clear();
            if (sol == null)
            {
                throw new ArgumentException("Could not create Gaussian process model");
            }

            numberOfParameters = pd.Dataset.Rows + 1
                                 + Regression.CovarianceFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count())
                                 + Regression.MeanFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count());
            return(sol.Model);
        }
Ejemplo n.º 3
0
 private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner)
     : base(original, cloner)
 {
 }
    public override IOperation Apply() {
      if (ModelParameter.ActualValue != null && CreateSolutionParameter.ActualValue.Value == true) {
        var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone();
        m.FixParameters();
        var data = (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone();
        var s = new GaussianProcessRegressionSolution(m, data);


        SolutionParameter.ActualValue = s;
        var results = ResultsParameter.ActualValue;
        if (!results.ContainsKey(SolutionParameterName)) {
          results.Add(new Result(SolutionParameterName, "The Gaussian process regression solution", s));
          results.Add(new Result(TrainingRSquaredResultName,
                                 "The Pearson's R² of the Gaussian process solution on the training partition.",
                                 new DoubleValue(s.TrainingRSquared)));
          results.Add(new Result(TestRSquaredResultName,
                                 "The Pearson's R² of the Gaussian process solution on the test partition.",
                                 new DoubleValue(s.TestRSquared)));
        } else {
          results[SolutionParameterName].Value = s;
          results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared);
          results[TestRSquaredResultName].Value = new DoubleValue(s.TestRSquared);
        }
      }
      return base.Apply();
    }
 private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner)
   : base(original, cloner) {
   evaluationCache = new Dictionary<int, double>(original.evaluationCache);
 }
Ejemplo n.º 6
0
 private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner)
     : base(original, cloner)
 {
     evaluationCache = new Dictionary <int, double>(original.evaluationCache);
 }
 private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner)
   : base(original, cloner) { }