Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/07/17 19:49:23 (7 years ago)
Author:
gkronber
Message:

experimentation

Location:
branches/MathNetNumerics-Exploration-2789
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/SBART.cs

    r15458 r15459  
    125125
    126126      int n = x.Length;
    127       float[] leverage = new float[n];
    128       float[] y_smoothed = new float[n];
    129127      int ic = n - 1;
    130128      int ier = -99;
     
    133131
    134132      float crit = -99.0f;
    135       int icrit = 0; // 0..don't calc CV,  1 .. GCV, 2 CV
     133      int icrit = 1; // 0..don't calc CV,  1 .. GCV, 2 CV
    136134
    137135      // float smoothingParameter = -99.0f;
    138       int smoothingParameterIndicator = 1;
     136      int smoothingParameterIndicator = 0;
    139137      float lowerSmoothingParameter = 0f;
    140138      float upperSmoothingParameter = 1.0f;
     
    153151        SBART.setreg_x64(xs, ys, ws,
    154152          ref n, xw, ref nx, ref min, ref range, knots, ref nk);
    155         if(nx < 4) {
     153
     154        /* use all points as knot points
     155        nk = nx + 2;
     156        knots[0] = xs[0];
     157        knots[1] = xs[0];
     158        knots[2] = xs[0];
     159        Array.Copy(xs, 0, knots, 3, nx);
     160        knots[nx + 3] = xs[nx - 1];
     161        knots[nx + 4] = xs[nx - 1];
     162        knots[nx + 5] = xs[nx - 1];
     163        */
     164
     165        // use uniform grid of knots
     166        nk = 20;
     167        knots = new float[nk + 4];
     168        knots[0] = xs[0];
     169        knots[1] = xs[0];
     170        knots[2] = xs[0];
     171        for(int i = 3; i<nk+1;i++) {
     172          knots[i] = (i-3f) / (nk-1);
     173        }
     174        knots[nk] = xs[nx - 1];
     175        knots[nk + 1] = xs[nx - 1];
     176        knots[nk + 2] = xs[nx - 1];
     177        knots[nk + 3] = xs[nx - 1];
     178
     179        if (nx < 4) {
    156180          report = new SBART_Report();
    157181          report.leverage = new double[0];
     
    160184
    161185        float[] coeff = new float[nk];
     186        float[] leverage = new float[nx];
     187        float[] y_smoothed = new float[nx];
     188
    162189
    163190        // working arrays for sbart
     
    172199        float[] sg3 = new float[nk];
    173200        int ld4 = 4;
    174         float[,] adb = new float[nk, ld4];
     201        float[,] adb = new float[ld4, nk];
    175202
    176203        float[,] p1ip = new float[nk, ld4];
    177204        int ldnk = nk + 4;
    178         float[,] p2ip = new float[nk, ldnk];
    179 
    180         SBART.sbart_x64(xs, ys, ws, ref nx, knots, ref nk, coeff, y_smoothed, leverage, ref crit, ref icrit,
     205        float[,] p2ip = new float[nk, nx];
     206
     207        SBART.sbart_x64(xs.Take(nx).ToArray(), ys.Take(nx).ToArray(), ws.Take(nx).ToArray(), ref nx,
     208          knots, ref nk,
     209          coeff, y_smoothed, leverage,
     210          ref crit, ref icrit,
    181211          ref smoothingParameter, ref smoothingParameterIndicator, ref lowerSmoothingParameter, ref upperSmoothingParameter,
    182212          ref tol, ref isetup,
  • branches/MathNetNumerics-Exploration-2789/Main/Program.cs

    r15450 r15459  
    1212  class Program {
    1313    static void Main(string[] args) {
    14       var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
    15       var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Poly")));
    16       // var provider = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider();
    17       // var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Chem")));
     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
     18      alglib.hqrndstate state;
     19      alglib.hqrndseed(1234, 5678, out state);
     20      var ys_noise = ys.Select(yi => yi + alglib.hqrndnormal(state) * 0.01).ToArray();
     21
     22      SBART.SBART_Report rep;
     23      SBART.CalculateSBART(xs, ys_noise, "y", new string[] { "x" }, 1.0f, out rep);
     24
     25
     26      // var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
     27      // var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Poly")));
     28      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider();
     29      var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Chem")));
    1830
    1931      var gam = new GAM();
    2032      gam.MaxIterations = 10;
    21       gam.MaxInteractions = 3;
     33      gam.MaxInteractions = 1;
    2234      gam.Problem.ProblemData = problemData;
    2335      gam.Start();
Note: See TracChangeset for help on using the changeset viewer.