Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/19 15:46:20 (6 years ago)
Author:
mkommend
Message:

#2952: Intermediate commit of refactoring RF models that is not yet finished.

Location:
branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesAlgorithm.cs

    r17030 r17045  
    269269
    270270        if (ModelCreation == ModelCreation.SurrogateModel) {
    271           model = new GradientBoostedTreesModelSurrogate(problemData, (uint)Seed, lossFunction, Iterations, MaxSize, R, M, Nu, (GradientBoostedTreesModel)model);
     271          model = new GradientBoostedTreesModelSurrogate((GradientBoostedTreesModel)model, problemData, (uint)Seed, lossFunction, Iterations, MaxSize, R, M, Nu);
    272272        }
    273273
  • branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModel.cs

    r17030 r17045  
    3434  // this is essentially a collection of weighted regression models
    3535  public sealed class GradientBoostedTreesModel : RegressionModel, IGradientBoostedTreesModel {
    36     // BackwardsCompatibility3.4 for allowing deserialization & serialization of old models
    37     #region Backwards compatible code, remove with 3.5
    38 
    3936    [Storable(Name = "models")]
    4037    private IList<IRegressionModel> __persistedModels {
     
    5350      get { return weights; }
    5451    }
    55     #endregion
    5652
    5753    public override IEnumerable<string> VariablesUsedForPrediction {
  • branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs

    r16565 r17045  
    9090    private Func<IGradientBoostedTreesModel> CreateLazyInitFunc(IGradientBoostedTreesModel clonedModel) {
    9191      return () => {
    92         return clonedModel == null ? RecalculateModel() : clonedModel;
     92        return clonedModel ?? RecalculateModel();
    9393      };
    9494    }
    9595
    9696    // create only the surrogate model without an actual model
    97     public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed,
     97    private GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed,
    9898      ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu)
    9999      : base(trainingProblemData.TargetVariable, "Gradient boosted tree model", string.Empty) {
     
    106106      this.m = m;
    107107      this.nu = nu;
     108
     109      actualModel = new Lazy<IGradientBoostedTreesModel>(() => RecalculateModel());
    108110    }
    109111
    110112    // wrap an actual model in a surrograte
    111     public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed,
    112       ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu,
    113       IGradientBoostedTreesModel model)
     113    public GradientBoostedTreesModelSurrogate(IGradientBoostedTreesModel model, IRegressionProblemData trainingProblemData, uint seed,
     114      ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu)
    114115      : this(trainingProblemData, seed, lossFunction, iterations, maxSize, r, m, nu) {
    115116      actualModel = new Lazy<IGradientBoostedTreesModel>(() => model);
Note: See TracChangeset for help on using the changeset viewer.