Changeset 15459
 Timestamp:
 11/07/17 19:49:23 (22 months ago)
 Location:
 branches/MathNetNumericsExploration2789
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

branches/MathNetNumericsExploration2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/SBART.cs
r15458 r15459 125 125 126 126 int n = x.Length; 127 float[] leverage = new float[n];128 float[] y_smoothed = new float[n];129 127 int ic = n  1; 130 128 int ier = 99; … … 133 131 134 132 float crit = 99.0f; 135 int icrit = 0; // 0..don't calc CV, 1 .. GCV, 2 CV133 int icrit = 1; // 0..don't calc CV, 1 .. GCV, 2 CV 136 134 137 135 // float smoothingParameter = 99.0f; 138 int smoothingParameterIndicator = 1;136 int smoothingParameterIndicator = 0; 139 137 float lowerSmoothingParameter = 0f; 140 138 float upperSmoothingParameter = 1.0f; … … 153 151 SBART.setreg_x64(xs, ys, ws, 154 152 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] = (i3f) / (nk1); 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) { 156 180 report = new SBART_Report(); 157 181 report.leverage = new double[0]; … … 160 184 161 185 float[] coeff = new float[nk]; 186 float[] leverage = new float[nx]; 187 float[] y_smoothed = new float[nx]; 188 162 189 163 190 // working arrays for sbart … … 172 199 float[] sg3 = new float[nk]; 173 200 int ld4 = 4; 174 float[,] adb = new float[ nk, ld4];201 float[,] adb = new float[ld4, nk]; 175 202 176 203 float[,] p1ip = new float[nk, ld4]; 177 204 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, 181 211 ref smoothingParameter, ref smoothingParameterIndicator, ref lowerSmoothingParameter, ref upperSmoothingParameter, 182 212 ref tol, ref isetup, 
branches/MathNetNumericsExploration2789/Main/Program.cs
r15450 r15459 12 12 class Program { 13 13 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"))); 18 30 19 31 var gam = new GAM(); 20 32 gam.MaxIterations = 10; 21 gam.MaxInteractions = 3;33 gam.MaxInteractions = 1; 22 34 gam.Problem.ProblemData = problemData; 23 35 gam.Start();
Note: See TracChangeset
for help on using the changeset viewer.