1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Globalization;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading;
|
---|
7 | using System.Threading.Tasks;
|
---|
8 | using HeuristicLab.Algorithms.DataAnalysis.Experimental;
|
---|
9 | using HeuristicLab.Problems.DataAnalysis;
|
---|
10 |
|
---|
11 | namespace 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 | }
|
---|