Changeset 15449 for branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/Splines.cs
- Timestamp:
- 11/03/17 20:28:37 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/Splines.cs
r15442 r15449 68 68 "Smoothing Spline (Reinsch with automatic tolerance determination using LOOCV)", 69 69 "B-Spline Smoothing", 70 "Penalized Regression Spline (alglib)" 70 "Penalized Regression Spline (alglib)", 71 "CUBGCV" 71 72 }.Select(s => new StringValue(s))); 72 73 73 Parameters.Add(new ConstrainedValueParameter<StringValue>("Type", "The type of spline (as supported by alglib)", validTypes, validTypes. First()));74 Parameters.Add(new ConstrainedValueParameter<StringValue>("Type", "The type of spline (as supported by alglib)", validTypes, validTypes.Last())); 74 75 Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "Regularization parameter for smoothing splines (0..+inf)", new DoubleValue(100))); 75 76 Parameters.Add(new ValueParameter<DoubleValue>("StdDev (noise)", "Known error in y values. Used only be Reinsch Smoothing Splines", new DoubleValue(0.1))); … … 151 152 Results.Add(new Result("Optimal tolerance", new DoubleValue(optTol))); 152 153 Results.Add(new Result("RMSE (LOO-CV)", new DoubleValue(looRMSE))); 154 break; 155 } 156 case "CUBGCV": { 157 CubicSplineGCV.CubGcvReport report; 158 var model = 159 CubicSplineGCV.CalculateCubicSpline(x, y, 160 Problem.ProblemData.TargetVariable, inputVars, out report); 161 var targetVar = Problem.ProblemData.TargetVariable; 162 var problemData = (IRegressionProblemData)Problem.ProblemData.Clone(); 163 Results.Add(new Result("Solution", model.CreateRegressionSolution(problemData))); 164 Results.Add(new Result("GCV", new DoubleValue(report.generalizedCrossValidation))); 165 Results.Add(new Result("Estimated error variance", new DoubleValue(report.estimatedErrorVariance))); 166 Results.Add(new Result("Estimated RSS degrees of freedom", new DoubleValue(report.estimatedRSSDegreesOfFreedom))); 167 Results.Add(new Result("Estimated treu mean squared error at data points", new DoubleValue(report.estimatedTrueMeanSquaredErrorAtDataPoints))); 168 Results.Add(new Result("Mean square of DF", new DoubleValue(report.meanSquareOfDf))); 169 Results.Add(new Result("Mean square residual", new DoubleValue(report.meanSquareResiudal))); 170 Results.Add(new Result("Smoothing parameter (optimized for GCV)", new DoubleValue(report.smoothingParameter))); 153 171 break; 154 172 } … … 489 507 } 490 508 509 // extrapolate for xx > x[n2] 510 b[b.Length] = b[b.Length - 1]; 511 d[1] = 0; 512 491 513 return new ReinschSmoothingSplineModel(a, b, c, d, x, targetVar, inputVars); 492 514 } … … 550 572 } 551 573 552 p rivatestatic void SortAndBin(double[] x, double[] y, double[] w, out double[] x2, out double[] y2, out double[] w2, bool scaling = false) {574 public static void SortAndBin(double[] x, double[] y, double[] w, out double[] x2, out double[] y2, out double[] w2, bool scaling = false) { 553 575 var sortedIdx = Enumerable.Range(0, x.Length).ToArray(); 554 576 // sort by x … … 679 701 this.scale = scale; 680 702 this.offset = offset; 681 682 // extrapolate for xx > x[n2]683 b[b.Length] = b[b.Length - 1];684 d[1] = 0;685 // d[b.Length] = -d[d.Length - 1];686 703 } 687 704 … … 695 712 696 713 public double GetEstimatedValue(double xx) { 697 int n = x.Length;714 int n = a.Length; 698 715 if (xx <= x[1]) { 699 716 double h = xx - x[1];
Note: See TracChangeset
for help on using the changeset viewer.