Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/10/12 13:31:13 (10 years ago)
Author:
gkronber
Message:

#1947: added degree parameter for the polynomial kernel of the SVM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs

    r8609 r8613  
    4646    private const string GammaParameterName = "Gamma";
    4747    private const string EpsilonParameterName = "Epsilon";
     48    private const string DegreeParameterName = "Degree";
    4849
    4950    #region parameter properties
     
    6566    public IValueParameter<DoubleValue> EpsilonParameter {
    6667      get { return (IValueParameter<DoubleValue>)Parameters[EpsilonParameterName]; }
     68    }
     69    public IValueParameter<IntValue> DegreeParameter {
     70      get { return (IValueParameter<IntValue>)Parameters[DegreeParameterName]; }
    6771    }
    6872    #endregion
     
    8791    public DoubleValue Epsilon {
    8892      get { return EpsilonParameter.Value; }
     93    }
     94    public IntValue Degree {
     95      get { return DegreeParameter.Value; }
    8996    }
    9097    #endregion
     
    112119      Parameters.Add(new ValueParameter<DoubleValue>(GammaParameterName, "The value of the gamma parameter in the kernel function.", new DoubleValue(1.0)));
    113120      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)));
    114122    }
    115123    [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    }
    117130
    118131    public override IDeepCloneable Clone(Cloner cloner) {
     
    127140      int nSv;
    128141      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,
    130143        out trainR2, out testR2, out nSv);
    131144
     
    137150
    138151    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,
    140153      out double trainingR2, out double testR2, out int nSv) {
    141154      Dataset dataset = problemData.Dataset;
     
    154167      parameter.probability = 0;
    155168      parameter.eps = 0.001;
    156       parameter.degree = 3;
     169      parameter.degree = degree;
    157170      parameter.shrinking = 1;
    158171      parameter.coef0 = 0;
Note: See TracChangeset for help on using the changeset viewer.