Changeset 14891 for branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/PolysplineKernel.cs
- Timestamp:
- 04/26/17 11:06:51 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/PolysplineKernel.cs
r14887 r14891 22 22 using System; 23 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 28 … … 28 30 [StorableClass] 29 31 // conditionally positive definite. (need to add polynomials) see http://num.math.uni-goettingen.de/schaback/teaching/sc.pdf 30 [Item("PolysplineKernel", "A kernel function that uses the poly -spline function ||x-c||^Beta.")]32 [Item("PolysplineKernel", "A kernel function that uses the polyharmonic function (||x-c||/Beta)^Degree as given in http://num.math.uni-goettingen.de/schaback/teaching/sc.pdf with beta as a scaling parameters.")] 31 33 public class PolysplineKernel : KernelBase { 34 35 #region Parameternames 36 private const string DegreeParameterName = "Degree"; 37 #endregion 38 #region Parameterproperties 39 public IFixedValueParameter<DoubleValue> DegreeParameter 40 { 41 get { return Parameters[DegreeParameterName] as IFixedValueParameter<DoubleValue>; } 42 } 43 #endregion 44 #region Properties 45 public DoubleValue Degree 46 { 47 get { return DegreeParameter.Value; } 48 } 49 #endregion 32 50 33 51 #region HLConstructors & Boilerplate … … 36 54 [StorableHook(HookType.AfterDeserialization)] 37 55 private void AfterDeserialization() { } 38 protected PolysplineKernel(PolysplineKernel original, Cloner cloner) 39 : base(original, cloner) { } 56 protected PolysplineKernel(PolysplineKernel original, Cloner cloner) : base(original, cloner) { } 40 57 public PolysplineKernel() { 58 Parameters.Add(new FixedValueParameter<DoubleValue>(DegreeParameterName, "The degree of the kernel. Needs to be greater than zero.", new DoubleValue(1.0))); 41 59 } 42 60 public override IDeepCloneable Clone(Cloner cloner) { … … 46 64 47 65 protected override double Get(double norm) { 48 return Math.Pow(norm, Beta.Value); 66 var beta = Beta.Value; 67 if (Math.Abs(beta) < double.Epsilon) return double.NaN; 68 var d = norm / beta; 69 return Math.Pow(d, Degree.Value); 49 70 } 50 71 72 //-degree/beta * (norm/beta)^degree 51 73 protected override double GetGradient(double norm) { 52 return Math.Pow(norm, Beta.Value) * Math.Log(norm); 74 var beta = Beta.Value; 75 if (Math.Abs(beta) < double.Epsilon) return double.NaN; 76 var d = norm / beta; 77 return -Degree.Value / beta * Math.Pow(d, Degree.Value); 53 78 } 54 79 }
Note: See TracChangeset
for help on using the changeset viewer.