Changeset 9096 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis
- Timestamp:
- 01/03/13 14:21:09 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs
r8623 r9096 22 22 23 23 using System; 24 using System.Linq; 24 25 using HeuristicLab.Algorithms.GradientDescent; 25 26 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.PluginInfrastructure; 32 34 using HeuristicLab.Problems.DataAnalysis; 33 35 … … 39 41 [Creatable("Data Analysis")] 40 42 [StorableClass] 41 public sealed class GaussianProcessClassification : EngineAlgorithm, IStorableContent {43 public sealed class GaussianProcessClassification : GaussianProcessBase, IStorableContent { 42 44 public string Filename { get; set; } 43 45 … … 48 50 } 49 51 50 private const string MeanFunctionParameterName = "MeanFunction"; 51 private const string CovarianceFunctionParameterName = "CovarianceFunction"; 52 private const string MinimizationIterationsParameterName = "Iterations"; 53 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 54 private const string SeedParameterName = "Seed"; 55 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 52 private const string ModelParameterName = "Model"; 56 53 57 54 #region parameter properties 58 public I ValueParameter<IMeanFunction> MeanFunctionParameter {59 get { return (I ValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }55 public IConstrainedValueParameter<IGaussianProcessClassificationModelCreator> ModelCreatorParameter { 56 get { return (IConstrainedValueParameter<IGaussianProcessClassificationModelCreator>)Parameters[ModelCreatorParameterName]; } 60 57 } 61 public I ValueParameter<ICovarianceFunction> CovarianceFunctionParameter {62 get { return (I ValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }58 public IFixedValueParameter<GaussianProcessClassificationSolutionCreator> SolutionCreatorParameter { 59 get { return (IFixedValueParameter<GaussianProcessClassificationSolutionCreator>)Parameters[SolutionCreatorParameterName]; } 63 60 } 64 public IValueParameter<IntValue> MinimizationIterationsParameter {65 get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }66 }67 public IValueParameter<IntValue> SeedParameter {68 get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }69 }70 public IValueParameter<BoolValue> SetSeedRandomlyParameter {71 get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }72 }73 #endregion74 #region properties75 public IMeanFunction MeanFunction {76 set { MeanFunctionParameter.Value = value; }77 get { return MeanFunctionParameter.Value; }78 }79 public ICovarianceFunction CovarianceFunction {80 set { CovarianceFunctionParameter.Value = value; }81 get { return CovarianceFunctionParameter.Value; }82 }83 public int MinimizationIterations {84 set { MinimizationIterationsParameter.Value.Value = value; }85 get { return MinimizationIterationsParameter.Value.Value; }86 }87 public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }88 public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }89 61 #endregion 90 62 … … 93 65 private GaussianProcessClassification(GaussianProcessClassification original, Cloner cloner) 94 66 : base(original, cloner) { 67 RegisterEventHandlers(); 95 68 } 96 69 public GaussianProcessClassification() 97 : base( ) {70 : base(new ClassificationProblem()) { 98 71 this.name = ItemName; 99 72 this.description = ItemDescription; 100 73 101 Problem = new ClassificationProblem(); 74 var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessClassificationModelCreator>(); 75 var defaultModelCreator = modelCreators.First(c => c is GaussianProcessClassificationModelCreator); 102 76 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 CovarianceSquaredExponentialIso())); 105 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 106 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 107 Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 77 // GP regression and classification algorithms only differ in the model and solution creators, 78 // thus we use a common base class and use operator parameters to implement the specific versions. 79 // Different model creators can be implemented, 80 // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators 81 Parameters.Add(new ConstrainedValueParameter<IGaussianProcessClassificationModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.", 82 new ItemSet<IGaussianProcessClassificationModelCreator>(modelCreators), defaultModelCreator)); 83 // this parameter is not intended to be changed, 84 Parameters.Add(new FixedValueParameter<GaussianProcessClassificationSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm", 85 new GaussianProcessClassificationSolutionCreator())); 86 Parameters[SolutionCreatorParameterName].Hidden = true; 108 87 109 Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false))); 110 Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed 111 112 var randomCreator = new HeuristicLab.Random.RandomCreator(); 113 var gpInitializer = new GaussianProcessHyperparameterInitializer(); 114 var bfgsInitializer = new LbfgsInitializer(); 115 var makeStep = new LbfgsMakeStep(); 116 var branch = new ConditionalBranch(); 117 var modelCreator = new GaussianProcessClassificationModelCreator(); 118 var updateResults = new LbfgsUpdateResults(); 119 var analyzer = new LbfgsAnalyzer(); 120 var finalModelCreator = new GaussianProcessClassificationModelCreator(); 121 var finalAnalyzer = new LbfgsAnalyzer(); 122 var solutionCreator = new GaussianProcessClassificationSolutionCreator(); 123 124 OperatorGraph.InitialOperator = randomCreator; 125 randomCreator.SeedParameter.ActualName = SeedParameterName; 126 randomCreator.SeedParameter.Value = null; 127 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName; 128 randomCreator.SetSeedRandomlyParameter.Value = null; 129 randomCreator.Successor = gpInitializer; 130 131 gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 132 gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 133 gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name; 135 gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name; 136 gpInitializer.Successor = bfgsInitializer; 137 138 bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName; 139 bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 140 bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 141 bfgsInitializer.Successor = makeStep; 142 143 makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 144 makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 145 makeStep.Successor = branch; 146 147 branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name; 148 branch.FalseBranch = modelCreator; 149 branch.TrueBranch = finalModelCreator; 150 151 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 152 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 153 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 154 modelCreator.Successor = updateResults; 155 156 updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 157 updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 158 updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 159 updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 160 updateResults.Successor = analyzer; 161 162 analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 163 analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 164 analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 165 analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 166 analyzer.PointsTableParameter.ActualName = "Hyperparameter table"; 167 analyzer.QualityGradientsTableParameter.ActualName = "Gradients table"; 168 analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table"; 169 analyzer.Successor = makeStep; 170 171 finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 172 finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 173 finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 174 finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName; 175 finalModelCreator.Successor = finalAnalyzer; 176 177 finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 178 finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 179 finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 180 finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName; 181 finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName; 182 finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName; 183 finalAnalyzer.Successor = solutionCreator; 184 185 solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name; 186 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 88 ParameterizedModelCreators(); 89 ParameterizeSolutionCreator(SolutionCreatorParameter.Value); 90 RegisterEventHandlers(); 187 91 } 188 92 93 189 94 [StorableHook(HookType.AfterDeserialization)] 190 private void AfterDeserialization() { } 95 private void AfterDeserialization() { 96 RegisterEventHandlers(); 97 } 191 98 192 99 public override IDeepCloneable Clone(Cloner cloner) { 193 100 return new GaussianProcessClassification(this, cloner); 194 101 } 102 103 #region events 104 private void RegisterEventHandlers() { 105 ModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged; 106 } 107 108 private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) { 109 ParameterizedModelCreator(ModelCreatorParameter.Value); 110 } 111 #endregion 112 113 private void ParameterizedModelCreators() { 114 foreach (var creator in ModelCreatorParameter.ValidValues) { 115 ParameterizedModelCreator(creator); 116 } 117 } 118 119 private void ParameterizedModelCreator(IGaussianProcessClassificationModelCreator modelCreator) { 120 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 121 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 122 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 123 124 // parameter names fixed by the algorithm 125 modelCreator.ModelParameter.ActualName = ModelParameterName; 126 modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName; 127 modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName; 128 modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName; 129 } 130 131 private void ParameterizeSolutionCreator(GaussianProcessClassificationSolutionCreator solutionCreator) { 132 solutionCreator.ModelParameter.ActualName = ModelParameterName; 133 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 } 195 135 } 196 136 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationModelCreator.cs
r8623 r9096 34 34 [Item(Name = "GaussianProcessClassificationModelCreator", 35 35 Description = "Creates a Gaussian process model for least-squares classification given the data, the hyperparameters, a mean function, and a covariance function.")] 36 public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator {36 public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator, IGaussianProcessClassificationModelCreator { 37 37 private const string ProblemDataParameterName = "ProblemData"; 38 38 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs
r8615 r9096 22 22 23 23 using System; 24 using System.Linq; 24 25 using HeuristicLab.Algorithms.GradientDescent; 25 26 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.PluginInfrastructure; 32 34 using HeuristicLab.Problems.DataAnalysis; 33 35 … … 39 41 [Creatable("Data Analysis")] 40 42 [StorableClass] 41 public sealed class GaussianProcessRegression : EngineAlgorithm, IStorableContent {43 public sealed class GaussianProcessRegression : GaussianProcessBase, IStorableContent { 42 44 public string Filename { get; set; } 43 45 … … 48 50 } 49 51 50 private const string MeanFunctionParameterName = "MeanFunction"; 51 private const string CovarianceFunctionParameterName = "CovarianceFunction"; 52 private const string MinimizationIterationsParameterName = "Iterations"; 53 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 54 private const string SeedParameterName = "Seed"; 55 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 52 private const string ModelParameterName = "Model"; 56 53 57 54 #region parameter properties 58 public I ValueParameter<IMeanFunction> MeanFunctionParameter {59 get { return (I ValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }55 public IConstrainedValueParameter<IGaussianProcessRegressionModelCreator> ModelCreatorParameter { 56 get { return (IConstrainedValueParameter<IGaussianProcessRegressionModelCreator>)Parameters[ModelCreatorParameterName]; } 60 57 } 61 public I ValueParameter<ICovarianceFunction> CovarianceFunctionParameter {62 get { return (I ValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }58 public IFixedValueParameter<GaussianProcessRegressionSolutionCreator> SolutionCreatorParameter { 59 get { return (IFixedValueParameter<GaussianProcessRegressionSolutionCreator>)Parameters[SolutionCreatorParameterName]; } 63 60 } 64 public IValueParameter<IntValue> MinimizationIterationsParameter {65 get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }66 }67 public IValueParameter<IntValue> SeedParameter {68 get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }69 }70 public IValueParameter<BoolValue> SetSeedRandomlyParameter {71 get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }72 }73 #endregion74 #region properties75 public IMeanFunction MeanFunction {76 set { MeanFunctionParameter.Value = value; }77 get { return MeanFunctionParameter.Value; }78 }79 public ICovarianceFunction CovarianceFunction {80 set { CovarianceFunctionParameter.Value = value; }81 get { return CovarianceFunctionParameter.Value; }82 }83 public int MinimizationIterations {84 set { MinimizationIterationsParameter.Value.Value = value; }85 get { return MinimizationIterationsParameter.Value.Value; }86 }87 public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }88 public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }89 61 #endregion 90 62 … … 93 65 private GaussianProcessRegression(GaussianProcessRegression original, Cloner cloner) 94 66 : base(original, cloner) { 67 RegisterEventHandlers(); 95 68 } 96 69 public GaussianProcessRegression() 97 : base( ) {70 : base(new RegressionProblem()) { 98 71 this.name = ItemName; 99 72 this.description = ItemDescription; 100 73 101 Problem = new RegressionProblem(); 74 var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessRegressionModelCreator>(); 75 var defaultModelCreator = modelCreators.First(c => c is GaussianProcessRegressionModelCreator); 102 76 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 CovarianceSquaredExponentialIso())); 105 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 106 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 107 Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 77 // GP regression and classification algorithms only differ in the model and solution creators, 78 // thus we use a common base class and use operator parameters to implement the specific versions. 79 // Different model creators can be implemented, 80 // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators 81 Parameters.Add(new ConstrainedValueParameter<IGaussianProcessRegressionModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.", 82 new ItemSet<IGaussianProcessRegressionModelCreator>(modelCreators), defaultModelCreator)); 83 // this parameter is not intended to be changed, 84 Parameters.Add(new FixedValueParameter<GaussianProcessRegressionSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm", 85 new GaussianProcessRegressionSolutionCreator())); 86 Parameters[SolutionCreatorParameterName].Hidden = true; 108 87 109 Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false))); 110 Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed 111 112 var randomCreator = new HeuristicLab.Random.RandomCreator(); 113 var gpInitializer = new GaussianProcessHyperparameterInitializer(); 114 var bfgsInitializer = new LbfgsInitializer(); 115 var makeStep = new LbfgsMakeStep(); 116 var branch = new ConditionalBranch(); 117 var modelCreator = new GaussianProcessRegressionModelCreator(); 118 var updateResults = new LbfgsUpdateResults(); 119 var analyzer = new LbfgsAnalyzer(); 120 var finalModelCreator = new GaussianProcessRegressionModelCreator(); 121 var finalAnalyzer = new LbfgsAnalyzer(); 122 var solutionCreator = new GaussianProcessRegressionSolutionCreator(); 123 124 OperatorGraph.InitialOperator = randomCreator; 125 randomCreator.SeedParameter.ActualName = SeedParameterName; 126 randomCreator.SeedParameter.Value = null; 127 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName; 128 randomCreator.SetSeedRandomlyParameter.Value = null; 129 randomCreator.Successor = gpInitializer; 130 131 gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 132 gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 133 gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name; 135 gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name; 136 gpInitializer.Successor = bfgsInitializer; 137 138 bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName; 139 bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 140 bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 141 bfgsInitializer.Successor = makeStep; 142 143 makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 144 makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 145 makeStep.Successor = branch; 146 147 branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name; 148 branch.FalseBranch = modelCreator; 149 branch.TrueBranch = finalModelCreator; 150 151 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 152 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 153 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 154 modelCreator.Successor = updateResults; 155 156 updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 157 updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 158 updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 159 updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 160 updateResults.Successor = analyzer; 161 162 analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 163 analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 164 analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 165 analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 166 analyzer.PointsTableParameter.ActualName = "Hyperparameter table"; 167 analyzer.QualityGradientsTableParameter.ActualName = "Gradients table"; 168 analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table"; 169 analyzer.Successor = makeStep; 170 171 finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 172 finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 173 finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 174 finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName; 175 finalModelCreator.Successor = finalAnalyzer; 176 177 finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 178 finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 179 finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 180 finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName; 181 finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName; 182 finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName; 183 finalAnalyzer.Successor = solutionCreator; 184 185 solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name; 186 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 88 ParameterizedModelCreators(); 89 ParameterizeSolutionCreator(SolutionCreatorParameter.Value); 90 RegisterEventHandlers(); 187 91 } 188 92 93 189 94 [StorableHook(HookType.AfterDeserialization)] 190 private void AfterDeserialization() { } 95 private void AfterDeserialization() { 96 RegisterEventHandlers(); 97 } 191 98 192 99 public override IDeepCloneable Clone(Cloner cloner) { 193 100 return new GaussianProcessRegression(this, cloner); 194 101 } 102 103 #region events 104 private void RegisterEventHandlers() { 105 ModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged; 106 } 107 108 private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) { 109 ParameterizedModelCreator(ModelCreatorParameter.Value); 110 } 111 #endregion 112 113 private void ParameterizedModelCreators() { 114 foreach (var creator in ModelCreatorParameter.ValidValues) { 115 ParameterizedModelCreator(creator); 116 } 117 } 118 119 private void ParameterizedModelCreator(IGaussianProcessRegressionModelCreator modelCreator) { 120 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 121 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 122 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 123 124 // parameter names fixed by the algorithm 125 modelCreator.ModelParameter.ActualName = ModelParameterName; 126 modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName; 127 modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName; 128 modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName; 129 } 130 131 private void ParameterizeSolutionCreator(GaussianProcessRegressionSolutionCreator solutionCreator) { 132 solutionCreator.ModelParameter.ActualName = ModelParameterName; 133 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 } 195 135 } 196 136 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs
r8484 r9096 34 34 [Item(Name = "GaussianProcessRegressionModelCreator", 35 35 Description = "Creates a Gaussian process model for regression given the data, the hyperparameters, a mean function, and a covariance function.")] 36 public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator {36 public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator, IGaussianProcessRegressionModelCreator { 37 37 private const string ProblemDataParameterName = "ProblemData"; 38 38 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
r8982 r9096 120 120 </Compile> 121 121 <Compile Include="FixedDataAnalysisAlgorithm.cs" /> 122 <Compile Include="GaussianProcess\GaussianProcessBase.cs" /> 122 123 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceConst.cs"> 123 124 <SubType>Code</SubType> … … 184 185 <Compile Include="GaussianProcess\GaussianProcessRegressionSolution.cs" /> 185 186 <Compile Include="GaussianProcess\ICovarianceFunction.cs" /> 187 <Compile Include="Interfaces\IGaussianProcessClassificationModelCreator.cs" /> 188 <Compile Include="Interfaces\IGaussianProcessRegressionModelCreator.cs" /> 189 <Compile Include="Interfaces\IGaussianProcessModelCreator.cs" /> 186 190 <Compile Include="Interfaces\IGaussianProcessModel.cs" /> 187 191 <Compile Include="Interfaces\IGaussianProcessSolution.cs" />
Note: See TracChangeset
for help on using the changeset viewer.