Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9338


Ignore:
Timestamp:
03/31/13 13:17:49 (12 years ago)
Author:
gkronber
Message:

#1967: minor adaptations necessary for the EuroCAST presentation

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  
        44*.testsettings
        55*.user
         6bin
  • branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/Form1.Designer.cs

    r9124 r9338  
    3232      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    3333      this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
     34      this.dataButton = new System.Windows.Forms.Button();
    3435      ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
    3536      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     
    3738      this.splitContainer1.Panel2.SuspendLayout();
    3839      this.splitContainer1.SuspendLayout();
     40      this.flowLayoutPanel1.SuspendLayout();
    3941      this.SuspendLayout();
    4042      //
     
    5759      series2.Name = "GP (mean)";
    5860      series3.ChartArea = "ChartArea1";
    59       series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
     61      series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint;
    6062      series3.Legend = "Legend1";
    6163      series3.Name = "GP SEiso (mean)";
     
    8789      // flowLayoutPanel1
    8890      //
     91      this.flowLayoutPanel1.Controls.Add(this.dataButton);
    8992      this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
    9093      this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
     
    9295      this.flowLayoutPanel1.Size = new System.Drawing.Size(735, 126);
    9396      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);
    94107      //
    95108      // Form1
     
    106119      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
    107120      this.splitContainer1.ResumeLayout(false);
     121      this.flowLayoutPanel1.ResumeLayout(false);
    108122      this.ResumeLayout(false);
    109123
     
    115129    private System.Windows.Forms.SplitContainer splitContainer1;
    116130    private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
     131    private System.Windows.Forms.Button dataButton;
    117132  }
    118133}
  • branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/Form1.cs

    r9212 r9338  
    1010using HeuristicLab.Algorithms.DataAnalysis;
    1111using HeuristicLab.Core;
     12using HeuristicLab.Data;
    1213using HeuristicLab.Problems.DataAnalysis;
    1314using HeuristicLab.Problems.Instances.DataAnalysis;
     
    2728
    2829      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);
    3033      sum.Terms.Add(new CovarianceNoise());
    3134      this.covFunction = sum;
     
    3841    private void UpdateSliders() {
    3942      flowLayoutPanel1.Controls.Clear();
     43      flowLayoutPanel1.Controls.Add(dataButton);
    4044      for (int i = 0; i < covFunction.GetNumberOfParameters(1); i++) {
    4145        var sliderControl = new TrackBar();
     
    4953
    5054    private void InitData() {
    51       int n = 20;
     55      int n = 200;
    5256      data = new List<List<double>>();
    5357      data.Add(ValueGenerator.GenerateSteps(0, 1, 1.0 / n).ToList());
     
    6973      }
    7074
     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
    7187      var allData = new List<List<double>>();
    7288      allData.Add(y);
    7389      allData.Add(data[0]);
    7490      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(),
    7896                                                (ICovarianceFunction)covFunction.Clone());
    79       var yPred = correctModel.GetEstimatedValues(ds, rows);
     97      var yPred = correctModel.GetEstimatedValues(fullDataSet, fullRows);
    8098      chart1.Series[1].Points.Clear();
    8199      foreach (var p in yPred.Zip(data[0], (t, x) => new { t, x })) {
     
    86104    private double[] GetSliderValues() {
    87105      var hyp = new List<double>();
    88       foreach (var slider in flowLayoutPanel1.Controls.Cast<TrackBar>()) {
     106      foreach (var slider in flowLayoutPanel1.Controls.OfType<TrackBar>()) {
    89107        Console.Write(slider.Value / 10.0 + " ");
    90108        hyp.Add(slider.Value / 10.0);
     
    94112      return hyp.ToArray();
    95113    }
     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    }
    96132  }
    97133}
  • branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessTuning.csproj

    r9212 r9338  
    156156    <Compile Include="TreeNodes.cs" />
    157157  </ItemGroup>
     158  <ItemGroup>
     159    <None Include="Plugin.cs.frame" />
     160    <None Include="Properties\AssemblyInfo.cs.frame" />
     161  </ItemGroup>
    158162  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
     163  <PropertyGroup>
     164    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     165set ProjectDir=$(ProjectDir)
     166set SolutionDir=$(SolutionDir)
     167set Outdir=$(Outdir)
     168
     169call PreBuildEvent.cmd
     170</PreBuildEvent>
     171  </PropertyGroup>
    159172  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    160173       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  
    178178  </ItemGroup>
    179179  <ItemGroup>
     180    <Compile Include="GaussianProcessRegressionDemo.cs" />
    180181    <Compile Include="GaussianProcess2dPeriodic.cs" />
    181182    <Compile Include="GaussianProcessRegressionInstance1D.cs" />
  • branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/VariousInstanceProvider.cs

    r9214 r9338  
    135135      {
    136136        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();
    137169        cov.Terms.Add(new CovarianceRationalQuadraticIso());
    138170        cov.Terms.Add(new CovarianceNoise());
Note: See TracChangeset for help on using the changeset viewer.