Changeset 9338
- Timestamp:
- 03/31/13 13:17:49 (12 years ago)
- Location:
- branches/HeuristicLab.Problems.GaussianProcessTuning
- Files:
-
- 3 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GaussianProcessTuning
- Property svn:ignore
-
old new 4 4 *.testsettings 5 5 *.user 6 bin
-
- Property svn:ignore
-
branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/Form1.Designer.cs
r9124 r9338 32 32 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 33 33 this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); 34 this.dataButton = new System.Windows.Forms.Button(); 34 35 ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); 35 36 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); … … 37 38 this.splitContainer1.Panel2.SuspendLayout(); 38 39 this.splitContainer1.SuspendLayout(); 40 this.flowLayoutPanel1.SuspendLayout(); 39 41 this.SuspendLayout(); 40 42 // … … 57 59 series2.Name = "GP (mean)"; 58 60 series3.ChartArea = "ChartArea1"; 59 series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Fast Line;61 series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 60 62 series3.Legend = "Legend1"; 61 63 series3.Name = "GP SEiso (mean)"; … … 87 89 // flowLayoutPanel1 88 90 // 91 this.flowLayoutPanel1.Controls.Add(this.dataButton); 89 92 this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 90 93 this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); … … 92 95 this.flowLayoutPanel1.Size = new System.Drawing.Size(735, 126); 93 96 this.flowLayoutPanel1.TabIndex = 0; 97 // 98 // dataButton 99 // 100 this.dataButton.Location = new System.Drawing.Point(3, 3); 101 this.dataButton.Name = "dataButton"; 102 this.dataButton.Size = new System.Drawing.Size(75, 23); 103 this.dataButton.TabIndex = 0; 104 this.dataButton.Text = "Data..."; 105 this.dataButton.UseVisualStyleBackColor = true; 106 this.dataButton.Click += new System.EventHandler(this.dataButton_Click); 94 107 // 95 108 // Form1 … … 106 119 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 107 120 this.splitContainer1.ResumeLayout(false); 121 this.flowLayoutPanel1.ResumeLayout(false); 108 122 this.ResumeLayout(false); 109 123 … … 115 129 private System.Windows.Forms.SplitContainer splitContainer1; 116 130 private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; 131 private System.Windows.Forms.Button dataButton; 117 132 } 118 133 } -
branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/Form1.cs
r9212 r9338 10 10 using HeuristicLab.Algorithms.DataAnalysis; 11 11 using HeuristicLab.Core; 12 using HeuristicLab.Data; 12 13 using HeuristicLab.Problems.DataAnalysis; 13 14 using HeuristicLab.Problems.Instances.DataAnalysis; … … 27 28 28 29 var sum = new CovarianceSum(); 29 sum.Terms.Add(new CovariancePeriodic()); 30 var t = new CovarianceSquaredExponentialIso(); 31 t.InverseLengthParameter.Value = new DoubleValue(1.0 / Math.Exp(-2)); 32 sum.Terms.Add(t); 30 33 sum.Terms.Add(new CovarianceNoise()); 31 34 this.covFunction = sum; … … 38 41 private void UpdateSliders() { 39 42 flowLayoutPanel1.Controls.Clear(); 43 flowLayoutPanel1.Controls.Add(dataButton); 40 44 for (int i = 0; i < covFunction.GetNumberOfParameters(1); i++) { 41 45 var sliderControl = new TrackBar(); … … 49 53 50 54 private void InitData() { 51 int n = 20 ;55 int n = 200; 52 56 data = new List<List<double>>(); 53 57 data.Add(ValueGenerator.GenerateSteps(0, 1, 1.0 / n).ToList()); … … 69 73 } 70 74 75 var trainingData = new List<List<double>>(); 76 var trainingIndices = RandomEnumerable.SampleRandomWithoutRepetition(Enumerable.Range(0, y.Count), random, 10); 77 var trainingY = trainingIndices.Select(i => y[i]).ToList(); 78 var trainingX = trainingIndices.Select(i => data[0][i]).ToList(); 79 trainingData.Add(trainingY); 80 trainingData.Add(trainingX); 81 82 //chart1.Series[2].Points.Clear(); 83 //foreach (var p in trainingY.Zip(trainingX, (t, x) => new { t, x })) { 84 // chart1.Series[2].Points.AddXY(p.x, p.t); 85 //} 86 71 87 var allData = new List<List<double>>(); 72 88 allData.Add(y); 73 89 allData.Add(data[0]); 74 90 var variableNames = new string[] { "y", "x" }; 75 var ds = new Dataset(variableNames, allData); 76 var rows = Enumerable.Range(0, data[0].Count); 77 var correctModel = new GaussianProcessModel(ds, variableNames.First(), variableNames.Skip(1), rows, hyp, new MeanZero(), 91 var fullDataSet = new Dataset(variableNames, allData); 92 var trainingDataSet = new Dataset(variableNames, trainingData); 93 var trainingRows = Enumerable.Range(0, trainingIndices.Count()); 94 var fullRows = Enumerable.Range(0, data[0].Count); 95 var correctModel = new GaussianProcessModel(fullDataSet, variableNames.First(), variableNames.Skip(1), fullRows, hyp, new MeanZero(), 78 96 (ICovarianceFunction)covFunction.Clone()); 79 var yPred = correctModel.GetEstimatedValues( ds, rows);97 var yPred = correctModel.GetEstimatedValues(fullDataSet, fullRows); 80 98 chart1.Series[1].Points.Clear(); 81 99 foreach (var p in yPred.Zip(data[0], (t, x) => new { t, x })) { … … 86 104 private double[] GetSliderValues() { 87 105 var hyp = new List<double>(); 88 foreach (var slider in flowLayoutPanel1.Controls. Cast<TrackBar>()) {106 foreach (var slider in flowLayoutPanel1.Controls.OfType<TrackBar>()) { 89 107 Console.Write(slider.Value / 10.0 + " "); 90 108 hyp.Add(slider.Value / 10.0); … … 94 112 return hyp.ToArray(); 95 113 } 114 115 private void dataButton_Click(object sender, EventArgs e) { 116 var dataForm = new Form(); 117 var dataTextField = new TextBox(); 118 dataTextField.Multiline = true; 119 dataTextField.Text = DataToText(); 120 dataTextField.Dock = DockStyle.Fill; 121 dataForm.Controls.Add(dataTextField); 122 dataForm.ShowDialog(); 123 } 124 125 private string DataToText() { 126 var str = new StringBuilder(); 127 foreach (var p in chart1.Series[1].Points) { 128 str.AppendLine(p.XValue + "\t" + p.YValues.First()); 129 } 130 return str.ToString(); 131 } 96 132 } 97 133 } -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessTuning.csproj
r9212 r9338 156 156 <Compile Include="TreeNodes.cs" /> 157 157 </ItemGroup> 158 <ItemGroup> 159 <None Include="Plugin.cs.frame" /> 160 <None Include="Properties\AssemblyInfo.cs.frame" /> 161 </ItemGroup> 158 162 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 163 <PropertyGroup> 164 <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 165 set ProjectDir=$(ProjectDir) 166 set SolutionDir=$(SolutionDir) 167 set Outdir=$(Outdir) 168 169 call PreBuildEvent.cmd 170 </PreBuildEvent> 171 </PropertyGroup> 159 172 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 160 173 Other similar extension points exist, see Microsoft.Common.targets. -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/Instances.DataAnalysis.GaussianProcessRegression-3.3.csproj
r9214 r9338 178 178 </ItemGroup> 179 179 <ItemGroup> 180 <Compile Include="GaussianProcessRegressionDemo.cs" /> 180 181 <Compile Include="GaussianProcess2dPeriodic.cs" /> 181 182 <Compile Include="GaussianProcessRegressionInstance1D.cs" /> -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/VariousInstanceProvider.cs
r9214 r9338 135 135 { 136 136 var cov = new CovarianceSum(); 137 cov.Terms.Add(new CovarianceSquaredExponentialIso()); 138 cov.Terms.Add(new CovarianceNoise()); 139 var hyp = new double[] { -2.5, 0, -7 }; 140 descriptorList.Add(new GaussianProcessRegressionDemo("1D: SE Noise", cov, hyp)); 141 } 142 { 143 var cov = new CovarianceSum(); 144 cov.Terms.Add(new CovarianceRationalQuadraticIso()); 145 cov.Terms.Add(new CovarianceNoise()); 146 var hyp = new double[] { -2.5, 0, -1, -7 }; 147 descriptorList.Add(new GaussianProcessRegressionDemo("1D: RQ Noise", cov, hyp)); 148 } 149 { 150 var cov = new CovarianceSum(); 151 var t = new CovarianceMaternIso(); 152 t.DParameter.Value = t.DParameter.ValidValues.First(x => x.Value == 3); 153 cov.Terms.Add(t); 154 cov.Terms.Add(new CovarianceNoise()); 155 var hyp = new double[] { -1.5, 0, -7 }; 156 descriptorList.Add(new GaussianProcessRegressionDemo("1D: Matern3 Noise", cov, hyp)); 157 } 158 { 159 var cov = new CovarianceSum(); 160 var t = new CovariancePeriodic(); 161 t.PeriodParameter.Value = new DoubleValue(0.3); 162 cov.Terms.Add(t); 163 cov.Terms.Add(new CovarianceNoise()); 164 var hyp = new double[] { 0, 0, -7 }; 165 descriptorList.Add(new GaussianProcessRegressionDemo("1D: Periodic Noise", cov, hyp)); 166 } 167 { 168 var cov = new CovarianceSum(); 137 169 cov.Terms.Add(new CovarianceRationalQuadraticIso()); 138 170 cov.Terms.Add(new CovarianceNoise());
Note: See TracChangeset
for help on using the changeset viewer.