Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2789_MathNetNumerics-Exploration/Main/Program.cs @ 16666

Last change on this file since 16666 was 15469, checked in by gkronber, 7 years ago

#2789 trying to get SBART to work correctly.

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.Linq;
5using System.Text;
6using System.Threading;
7using System.Threading.Tasks;
8using HeuristicLab.Algorithms.DataAnalysis.Experimental;
9using HeuristicLab.Problems.DataAnalysis;
10
11namespace Main {
12  class Program {
13    static void Main(string[] args) {
14
15       var xs = HeuristicLab.Common.SequenceGenerator.GenerateSteps(-3.5, 3.5, 0.02, includeEnd: true).ToArray();
16       var ys = xs.Select(xi => (1.0 / (Math.Sqrt(2 * Math.PI)) * Math.Exp(-0.5 * xi * xi))).ToArray();
17       var ws = xs.Select(_ => 1.0).ToArray();
18 
19       alglib.hqrndstate state;
20       alglib.hqrndseed(1234, 5678, out state);
21       var ys_noise = ys.Select(yi => yi + alglib.hqrndnormal(state) * 0.01).ToArray();
22 
23       SBART.SBART_Report rep;
24       SBART.CalculateSBART(xs, ys_noise, ws, 2, "y", new string[] { "x" }, out rep);
25
26
27      // var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
28      // var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Poly")));
29      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider();
30      var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Chem")));
31
32      var gam = new GAM();
33      gam.MaxIterations = 10;
34      gam.MaxInteractions = 1;
35      gam.Problem.ProblemData = problemData;
36      gam.Start();
37
38      var solution = (IRegressionSolution)gam.Results["Ensemble solution"].Value;
39
40      Console.WriteLine("RMSE (train) {0}", solution.TrainingRootMeanSquaredError);
41      Console.WriteLine("RMSE (test) {0}", solution.TestRootMeanSquaredError);
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.