Changeset 8494
- Timestamp:
- 08/16/12 16:33:50 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs
r8421 r8494 22 22 23 23 using System; 24 using System.Collections.Generic;25 using System.Linq;26 24 using HeuristicLab.Algorithms.GradientDescent; 27 25 using HeuristicLab.Common; … … 32 30 using HeuristicLab.Parameters; 33 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 using HeuristicLab.PluginInfrastructure;35 32 using HeuristicLab.Problems.DataAnalysis; 36 33 … … 59 56 60 57 #region parameter properties 61 public I ConstrainedValueParameter<IMeanFunction> MeanFunctionParameter {58 public IValueParameter<IMeanFunction> MeanFunctionParameter { 62 59 get { return (IConstrainedValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; } 63 60 } 64 public I ConstrainedValueParameter<ICovarianceFunction> CovarianceFunctionParameter {61 public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter { 65 62 get { return (IConstrainedValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; } 66 63 } … … 104 101 Problem = new RegressionProblem(); 105 102 106 List<IMeanFunction> meanFunctions = ApplicationManager.Manager.GetInstances<IMeanFunction>().ToList(); 107 List<ICovarianceFunction> covFunctions = ApplicationManager.Manager.GetInstances<ICovarianceFunction>().ToList(); 108 109 Parameters.Add(new ConstrainedValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", 110 new ItemSet<IMeanFunction>(meanFunctions), meanFunctions.OfType<MeanConst>().First())); 111 Parameters.Add(new ConstrainedValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", 112 new ItemSet<ICovarianceFunction>(covFunctions), covFunctions.OfType<CovarianceSEiso>().First())); 103 Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst())); 104 Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSEiso())); 113 105 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 114 106 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs
r8463 r8494 75 75 76 76 public override IOperation Apply() { 77 var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone(); 78 var data = (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone(); 79 var s = new GaussianProcessRegressionSolution(m, data); 77 if (ModelParameter.ActualValue != null) { 78 var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone(); 79 var data = (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone(); 80 var s = new GaussianProcessRegressionSolution(m, data); 80 81 81 82 82 SolutionParameter.ActualValue = s; 83 var results = ResultsParameter.ActualValue; 84 if (!results.ContainsKey(SolutionParameterName)) { 85 results.Add(new Result(SolutionParameterName, "The Gaussian process regression solution", s)); 86 results.Add(new Result(TrainingRSquaredResultName, "The Pearson's R² of the Gaussian process solution on the training partition.", new DoubleValue(s.TrainingRSquared))); 87 results.Add(new Result(TestRSquaredResultName, "The Pearson's R² of the Gaussian process solution on the test partition.", new DoubleValue(s.TestRSquared))); 88 } else { 89 results[SolutionParameterName].Value = s; 90 results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared); 91 results[TestRSquaredResultName].Value = new DoubleValue(s.TestRSquared); 83 SolutionParameter.ActualValue = s; 84 var results = ResultsParameter.ActualValue; 85 if (!results.ContainsKey(SolutionParameterName)) { 86 results.Add(new Result(SolutionParameterName, "The Gaussian process regression solution", s)); 87 results.Add(new Result(TrainingRSquaredResultName, 88 "The Pearson's R² of the Gaussian process solution on the training partition.", 89 new DoubleValue(s.TrainingRSquared))); 90 results.Add(new Result(TestRSquaredResultName, 91 "The Pearson's R² of the Gaussian process solution on the test partition.", 92 new DoubleValue(s.TestRSquared))); 93 } else { 94 results[SolutionParameterName].Value = s; 95 results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared); 96 results[TestRSquaredResultName].Value = new DoubleValue(s.TestRSquared); 97 } 92 98 } 93 99 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.