Changeset 14027 for stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.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/RandomForest/RandomForestModel.cs
r12702 r14027 34 34 [StorableClass] 35 35 [Item("RandomForestModel", "Represents a random forest for regression and classification.")] 36 public sealed class RandomForestModel : NamedItem, IRandomForestModel {36 public sealed class RandomForestModel : ClassificationModel, IRandomForestModel { 37 37 // not persisted 38 38 private alglib.decisionforest randomForest; … … 44 44 } 45 45 } 46 47 public override IEnumerable<string> VariablesUsedForPrediction { 48 get { return originalTrainingData.AllowedInputVariables; } 49 } 50 46 51 47 52 // instead of storing the data of the model itself … … 91 96 92 97 // random forest models can only be created through the static factory methods CreateRegressionModel and CreateClassificationModel 93 private RandomForestModel( alglib.decisionforest randomForest,98 private RandomForestModel(string targetVariable, alglib.decisionforest randomForest, 94 99 int seed, IDataAnalysisProblemData originalTrainingData, 95 100 int nTrees, double r, double m, double[] classValues = null) 96 : base( ) {101 : base(targetVariable) { 97 102 this.name = ItemName; 98 103 this.description = ItemDescription; … … 147 152 } 148 153 149 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {154 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 150 155 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows); 151 156 AssertInputMatrix(inputData); … … 174 179 } 175 180 176 public IRandomForestRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 177 return new RandomForestRegressionSolution(new RegressionProblemData(problemData), this); 178 } 179 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) { 180 return CreateRegressionSolution(problemData); 181 } 182 public IRandomForestClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 183 return new RandomForestClassificationSolution(new ClassificationProblemData(problemData), this); 184 } 185 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) { 186 return CreateClassificationSolution(problemData); 181 182 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 183 return new RandomForestRegressionSolution(this, new RegressionProblemData(problemData)); 184 } 185 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 186 return new RandomForestClassificationSolution(this, new ClassificationProblemData(problemData)); 187 187 } 188 188 … … 205 205 outOfBagRmsError = rep.oobrmserror; 206 206 207 return new RandomForestModel( dForest, seed, problemData, nTrees, r, m);207 return new RandomForestModel(problemData.TargetVariable, dForest, seed, problemData, nTrees, r, m); 208 208 } 209 209 … … 242 242 outOfBagRelClassificationError = rep.oobrelclserror; 243 243 244 return new RandomForestModel( dForest, seed, problemData, nTrees, r, m, classValues);244 return new RandomForestModel(problemData.TargetVariable, dForest, seed, problemData, nTrees, r, m, classValues); 245 245 } 246 246
Note: See TracChangeset
for help on using the changeset viewer.