Ignore:
Timestamp:
11/14/15 08:10:18 (5 years ago)
Author:
gkronber
Message:

#2450 made the changes suggested by mkommend in the review. This is definitely a big improvement, thx!

File:
1 edited

Legend:

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

    r13066 r13157  
    3333  // recalculate the actual GBT model on demand
    3434  [Item("Gradient boosted tree model", "")]
    35   public sealed class GradientBoostedTreesModelSurrogate : NamedItem, IRegressionModel {
     35  public sealed class GradientBoostedTreesModelSurrogate : NamedItem, IGradientBoostedTreesModel {
    3636    // don't store the actual model!
    37     private IRegressionModel actualModel; // the actual model is only recalculated when necessary
    38     public IRegressionModel Model { get { return actualModel; } }
     37    private IGradientBoostedTreesModel actualModel; // the actual model is only recalculated when necessary
    3938
    4039    [Storable]
     
    8786
    8887    // wrap an actual model in a surrograte
    89     public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu, IRegressionModel model)
     88    public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu, IGradientBoostedTreesModel model)
    9089      : this(trainingProblemData, seed, lossFunction, iterations, maxSize, r, m, nu) {
    9190      this.actualModel = model;
     
    107106
    108107
    109     private IRegressionModel RecalculateModel() {
     108    private IGradientBoostedTreesModel RecalculateModel() {
    110109      return GradientBoostedTreesAlgorithmStatic.TrainGbm(trainingProblemData, lossFunction, maxSize, nu, r, m, iterations, seed).Model;
     110    }
     111
     112    public IEnumerable<IRegressionModel> Models {
     113      get {
     114        if (actualModel == null) actualModel = RecalculateModel();
     115        return actualModel.Models;
     116      }
     117    }
     118
     119    public IEnumerable<double> Weights {
     120      get {
     121        if (actualModel == null) actualModel = RecalculateModel();
     122        return actualModel.Weights;
     123      }
    111124    }
    112125  }
Note: See TracChangeset for help on using the changeset viewer.