- Timestamp:
- 07/06/17 13:21:00 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/IKernel.cs
r14936 r15157 21 21 22 22 23 using System; 24 23 25 namespace HeuristicLab.Algorithms.DataAnalysis { 24 26 public interface IKernel : ICovarianceFunction { 25 27 double? Beta { get; set; } // a kernel parameter 26 28 IDistance Distance { get; set; } // the distance function to use 29 30 event EventHandler BetaChanged; 31 event EventHandler DistanceChanged; 27 32 } 28 33 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/KernelBase.cs
r15156 r15157 34 34 private const string DistanceParameterName = "Distance"; 35 35 36 public ValueParameter<IDistance> DistanceParameter {37 get { return Parameters[DistanceParameterName] as ValueParameter<IDistance>; }36 public IValueParameter<IDistance> DistanceParameter { 37 get { return (IValueParameter<IDistance>)Parameters[DistanceParameterName]; } 38 38 } 39 39 40 40 [Storable] 41 public double? Beta { get; set; } 41 private double? beta; 42 public double? Beta { 43 get { return beta; } 44 set { 45 if (value != beta) { 46 beta = value; 47 RaiseBetaChanged(); 48 } 49 } 50 } 42 51 43 52 public IDistance Distance { 44 53 get { return DistanceParameter.Value; } 45 set { DistanceParameter.Value = value; } 54 set { 55 if (DistanceParameter.Value != value) { 56 DistanceParameter.Value = value; 57 } 58 } 46 59 } 47 60 … … 51 64 protected KernelBase(KernelBase original, Cloner cloner) 52 65 : base(original, cloner) { 53 Beta = original.Beta; 66 beta = original.beta; 67 RegisterEvents(); 54 68 } 55 69 … … 57 71 Parameters.Add(new ValueParameter<IDistance>(DistanceParameterName, "The distance function used for kernel calculation")); 58 72 DistanceParameter.Value = new EuclideanDistance(); 73 RegisterEvents(); 74 } 75 76 [StorableHook(HookType.AfterDeserialization)] 77 private void AfterDeserialization() { 78 RegisterEvents(); 79 } 80 81 private void RegisterEvents() { 82 DistanceParameter.ValueChanged += (sender, args) => RaiseDistanceChanged(); 59 83 } 60 84 … … 94 118 return dist.Get(r1, r2); 95 119 } 120 121 #region events 122 public event EventHandler BetaChanged; 123 public event EventHandler DistanceChanged; 124 125 protected void RaiseBetaChanged() { 126 var handler = BetaChanged; 127 if (handler != null) handler(this, EventArgs.Empty); 128 } 129 130 protected void RaiseDistanceChanged() { 131 var handler = DistanceChanged; 132 if (handler != null) handler(this, EventArgs.Empty); 133 } 134 #endregion 96 135 } 97 136 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/PolysplineKernel.cs
r15156 r15157 36 36 37 37 public IFixedValueParameter<DoubleValue> DegreeParameter { 38 get { return Parameters[DegreeParameterName] as IFixedValueParameter<DoubleValue>; }38 get { return (IFixedValueParameter<DoubleValue>)Parameters[DegreeParameterName]; } 39 39 } 40 40 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/ThinPlatePolysplineKernel.cs
r15156 r15157 36 36 37 37 public IFixedValueParameter<DoubleValue> DegreeParameter { 38 get { return Parameters[DegreeParameterName] as IFixedValueParameter<DoubleValue>; }38 get { return (IFixedValueParameter<DoubleValue>)Parameters[DegreeParameterName]; } 39 39 } 40 40 public DoubleValue Degree {
Note: See TracChangeset
for help on using the changeset viewer.