Changeset 8613
- Timestamp:
- 09/10/12 13:31:13 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs
r8609 r8613 45 45 private const string NuParameterName = "Nu"; 46 46 private const string GammaParameterName = "Gamma"; 47 private const string DegreeParameterName = "Degree"; 47 48 48 49 #region parameter properties … … 61 62 public IValueParameter<DoubleValue> GammaParameter { 62 63 get { return (IValueParameter<DoubleValue>)Parameters[GammaParameterName]; } 64 } 65 public IValueParameter<IntValue> DegreeParameter { 66 get { return (IValueParameter<IntValue>)Parameters[DegreeParameterName]; } 63 67 } 64 68 #endregion … … 80 84 public DoubleValue Gamma { 81 85 get { return GammaParameter.Value; } 86 } 87 public IntValue Degree { 88 get { return DegreeParameter.Value; } 82 89 } 83 90 #endregion … … 104 111 Parameters.Add(new ValueParameter<DoubleValue>(CostParameterName, "The value of the C (cost) parameter of C-SVC.", new DoubleValue(1.0))); 105 112 Parameters.Add(new ValueParameter<DoubleValue>(GammaParameterName, "The value of the gamma parameter in the kernel function.", new DoubleValue(1.0))); 113 Parameters.Add(new ValueParameter<IntValue>(DegreeParameterName, "The degree parameter for the polynomial kernel function.", new IntValue(3))); 106 114 } 107 115 [StorableHook(HookType.AfterDeserialization)] 108 private void AfterDeserialization() { } 116 private void AfterDeserialization() { 117 #region backwards compatibility (change with 3.4) 118 if (!Parameters.ContainsKey(DegreeParameterName)) 119 Parameters.Add(new ValueParameter<IntValue>(DegreeParameterName, "The degree parameter for the polynomial kernel function.", new IntValue(3))); 120 #endregion 121 } 109 122 110 123 public override IDeepCloneable Clone(Cloner cloner) { … … 119 132 int nSv; 120 133 var solution = CreateSupportVectorClassificationSolution(problemData, selectedInputVariables, 121 SvmType.Value, KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, 134 SvmType.Value, KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, Degree.Value, 122 135 out trainingAccuracy, out testAccuracy, out nSv); 123 136 … … 129 142 130 143 public static SupportVectorClassificationSolution CreateSupportVectorClassificationSolution(IClassificationProblemData problemData, IEnumerable<string> allowedInputVariables, 131 string svmType, string kernelType, double cost, double nu, double gamma, 144 string svmType, string kernelType, double cost, double nu, double gamma, int degree, 132 145 out double trainingAccuracy, out double testAccuracy, out int nSv) { 133 146 Dataset dataset = problemData.Dataset; … … 145 158 parameter.probability = 0; 146 159 parameter.eps = 0.001; 147 parameter.degree = 3;160 parameter.degree = degree; 148 161 parameter.shrinking = 1; 149 162 parameter.coef0 = 0; -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs
r8609 r8613 46 46 private const string GammaParameterName = "Gamma"; 47 47 private const string EpsilonParameterName = "Epsilon"; 48 private const string DegreeParameterName = "Degree"; 48 49 49 50 #region parameter properties … … 65 66 public IValueParameter<DoubleValue> EpsilonParameter { 66 67 get { return (IValueParameter<DoubleValue>)Parameters[EpsilonParameterName]; } 68 } 69 public IValueParameter<IntValue> DegreeParameter { 70 get { return (IValueParameter<IntValue>)Parameters[DegreeParameterName]; } 67 71 } 68 72 #endregion … … 87 91 public DoubleValue Epsilon { 88 92 get { return EpsilonParameter.Value; } 93 } 94 public IntValue Degree { 95 get { return DegreeParameter.Value; } 89 96 } 90 97 #endregion … … 112 119 Parameters.Add(new ValueParameter<DoubleValue>(GammaParameterName, "The value of the gamma parameter in the kernel function.", new DoubleValue(1.0))); 113 120 Parameters.Add(new ValueParameter<DoubleValue>(EpsilonParameterName, "The value of the epsilon parameter for epsilon-SVR.", new DoubleValue(0.1))); 121 Parameters.Add(new ValueParameter<IntValue>(DegreeParameterName, "The degree parameter for the polynomial kernel function.", new IntValue(3))); 114 122 } 115 123 [StorableHook(HookType.AfterDeserialization)] 116 private void AfterDeserialization() { } 124 private void AfterDeserialization() { 125 #region backwards compatibility (change with 3.4) 126 if (!Parameters.ContainsKey(DegreeParameterName)) 127 Parameters.Add(new ValueParameter<IntValue>(DegreeParameterName, "The degree parameter for the polynomial kernel function.", new IntValue(3))); 128 #endregion 129 } 117 130 118 131 public override IDeepCloneable Clone(Cloner cloner) { … … 127 140 int nSv; 128 141 var solution = CreateSupportVectorRegressionSolution(problemData, selectedInputVariables, SvmType.Value, 129 KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value, 142 KernelType.Value, Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value, Degree.Value, 130 143 out trainR2, out testR2, out nSv); 131 144 … … 137 150 138 151 public static SupportVectorRegressionSolution CreateSupportVectorRegressionSolution(IRegressionProblemData problemData, IEnumerable<string> allowedInputVariables, 139 string svmType, string kernelType, double cost, double nu, double gamma, double epsilon, 152 string svmType, string kernelType, double cost, double nu, double gamma, double epsilon, int degree, 140 153 out double trainingR2, out double testR2, out int nSv) { 141 154 Dataset dataset = problemData.Dataset; … … 154 167 parameter.probability = 0; 155 168 parameter.eps = 0.001; 156 parameter.degree = 3;169 parameter.degree = degree; 157 170 parameter.shrinking = 1; 158 171 parameter.coef0 = 0;
Note: See TracChangeset
for help on using the changeset viewer.