Changeset 14027 for stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs
- Timestamp:
- 07/08/16 14:37:15 (8 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13826,13921-13922,13941,13992-13993,14000
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 13921-13922,13941,13992-13993,14000
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs
r13184 r14027 22 22 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 33 34 // recalculate the actual GBT model on demand 34 35 [Item("Gradient boosted tree model", "")] 35 public sealed class GradientBoostedTreesModelSurrogate : NamedItem, IGradientBoostedTreesModel {36 public sealed class GradientBoostedTreesModelSurrogate : RegressionModel, IGradientBoostedTreesModel { 36 37 // don't store the actual model! 37 38 private IGradientBoostedTreesModel actualModel; // the actual model is only recalculated when necessary … … 55 56 56 57 58 public override IEnumerable<string> VariablesUsedForPrediction { 59 get { return actualModel.Models.SelectMany(x => x.VariablesUsedForPrediction).Distinct().OrderBy(x => x); } 60 } 61 57 62 [StorableConstructor] 58 63 private GradientBoostedTreesModelSurrogate(bool deserializing) : base(deserializing) { } … … 73 78 74 79 // create only the surrogate model without an actual model 75 public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu) 76 : base("Gradient boosted tree model", string.Empty) { 80 public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, 81 ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu) 82 : base(trainingProblemData.TargetVariable, "Gradient boosted tree model", string.Empty) { 77 83 this.trainingProblemData = trainingProblemData; 78 84 this.seed = seed; … … 86 92 87 93 // wrap an actual model in a surrograte 88 public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu, IGradientBoostedTreesModel model) 94 public GradientBoostedTreesModelSurrogate(IRegressionProblemData trainingProblemData, uint seed, 95 ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu, 96 IGradientBoostedTreesModel model) 89 97 : this(trainingProblemData, seed, lossFunction, iterations, maxSize, r, m, nu) { 90 98 this.actualModel = model; … … 96 104 97 105 // forward message to actual model (recalculate model first if necessary) 98 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {106 public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 99 107 if (actualModel == null) actualModel = RecalculateModel(); 100 108 return actualModel.GetEstimatedValues(dataset, rows); 101 109 } 102 110 103 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {111 public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 104 112 return new RegressionSolution(this, (IRegressionProblemData)problemData.Clone()); 105 113 } 106 107 114 108 115 private IGradientBoostedTreesModel RecalculateModel() {
Note: See TracChangeset
for help on using the changeset viewer.