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/SupportVectorClassification.cs

    r8609 r8613  
    4545    private const string NuParameterName = "Nu";
    4646    private const string GammaParameterName = "Gamma";
     47    private const string DegreeParameterName = "Degree";
    4748
    4849    #region parameter properties
     
    6162    public IValueParameter<DoubleValue> GammaParameter {
    6263      get { return (IValueParameter<DoubleValue>)Parameters[GammaParameterName]; }
     64    }
     65    public IValueParameter<IntValue> DegreeParameter {
     66      get { return (IValueParameter<IntValue>)Parameters[DegreeParameterName]; }
    6367    }
    6468    #endregion
     
    8084    public DoubleValue Gamma {
    8185      get { return GammaParameter.Value; }
     86    }
     87    public IntValue Degree {
     88      get { return DegreeParameter.Value; }
    8289    }
    8390    #endregion
     
    104111      Parameters.Add(new ValueParameter<DoubleValue>(CostParameterName, "The value of the C (cost) parameter of C-SVC.", new DoubleValue(1.0)));
    105112      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)));
    106114    }
    107115    [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    }
    109122
    110123    public override IDeepCloneable Clone(Cloner cloner) {
     
    119132      int nSv;
    120133      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,
    122135        out trainingAccuracy, out testAccuracy, out nSv);
    123136
     
    129142
    130143    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,
    132145      out double trainingAccuracy, out double testAccuracy, out int nSv) {
    133146      Dataset dataset = problemData.Dataset;
     
    145158      parameter.probability = 0;
    146159      parameter.eps = 0.001;
    147       parameter.degree = 3;
     160      parameter.degree = degree;
    148161      parameter.shrinking = 1;
    149162      parameter.coef0 = 0;
Note: See TracChangeset for help on using the changeset viewer.