Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/15 18:35:05 (9 years ago)
Author:
gkronber
Message:

#2450 derived ILossFunction from IItem to allow execution on hive without privileged flag (made an "after deserialization"-hook necessary to convert the parameter type)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs

    r12868 r12873  
    4545    private readonly uint seed;
    4646    [Storable]
    47     private string lossFunctionName;
     47    private ILossFunction lossFunction;
    4848    [Storable]
    4949    private double r;
     
    6666
    6767      this.trainingProblemData = cloner.Clone(original.trainingProblemData);
     68      this.lossFunction = cloner.Clone(original.lossFunction);
    6869      this.seed = original.seed;
    69       this.lossFunctionName = original.lossFunctionName;
    7070      this.iterations = original.iterations;
    7171      this.maxSize = original.maxSize;
     
    7676
    7777    // create only the surrogate model without an actual model
    78     public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, string lossFunctionName, int iterations, int maxSize, double r, double m, double nu)
     78    public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu)
    7979      : base("Gradient boosted tree model", string.Empty) {
    8080      this.trainingProblemData = trainingProblemData;
    8181      this.seed = seed;
    82       this.lossFunctionName = lossFunctionName;
     82      this.lossFunction = lossFunction;
    8383      this.iterations = iterations;
    8484      this.maxSize = maxSize;
     
    8989
    9090    // wrap an actual model in a surrograte
    91     public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, string lossFunctionName, int iterations, int maxSize, double r, double m, double nu, IRegressionModel model)
    92       : this(trainingProblemData, seed, lossFunctionName, iterations, maxSize, r, m, nu) {
     91    public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu, IRegressionModel model)
     92      : this(trainingProblemData, seed, lossFunction, iterations, maxSize, r, m, nu) {
    9393      this.actualModel = model;
    9494    }
     
    110110
    111111    private IRegressionModel RecalculateModel() {
    112       var lossFunction = ApplicationManager.Manager.GetInstances<ILossFunction>().Single(l => l.ToString() == lossFunctionName);
    113112      return GradientBoostedTreesAlgorithmStatic.TrainGbm(trainingProblemData, lossFunction, maxSize, nu, r, m, iterations, seed).Model;
    114113    }
Note: See TracChangeset for help on using the changeset viewer.