- Timestamp:
- 07/08/16 14:37:15 (9 years ago)
- Location:
- stable
- Files:
-
- 7 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/RandomForestClassification.cs
r13297 r14027 143 143 144 144 if (CreateSolution) { 145 var solution = new RandomForestClassificationSolution( (IClassificationProblemData)Problem.ProblemData.Clone(), model);145 var solution = new RandomForestClassificationSolution(model, (IClassificationProblemData)Problem.ProblemData.Clone()); 146 146 Results.Add(new Result(RandomForestClassificationModelResultName, "The random forest classification solution.", solution)); 147 147 } 148 148 } 149 149 150 150 // keep for compatibility with old API 151 151 public static RandomForestClassificationSolution CreateRandomForestClassificationSolution(IClassificationProblemData problemData, int nTrees, double r, double m, int seed, 152 152 out double rmsError, out double relClassificationError, out double outOfBagRmsError, out double outOfBagRelClassificationError) { 153 153 var model = CreateRandomForestClassificationModel(problemData, nTrees, r, m, seed, out rmsError, out relClassificationError, out outOfBagRmsError, out outOfBagRelClassificationError); 154 return new RandomForestClassificationSolution( (IClassificationProblemData)problemData.Clone(), model);154 return new RandomForestClassificationSolution(model, (IClassificationProblemData)problemData.Clone()); 155 155 } 156 156 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassificationSolution.cs
r12009 r14027 43 43 : base(original, cloner) { 44 44 } 45 public RandomForestClassificationSolution(I ClassificationProblemData problemData, IRandomForestModel randomForestModel)45 public RandomForestClassificationSolution(IRandomForestModel randomForestModel, IClassificationProblemData problemData) 46 46 : base(randomForestModel, problemData) { 47 47 } -
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 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs
r13297 r14027 143 143 144 144 if (CreateSolution) { 145 var solution = new RandomForestRegressionSolution( (IRegressionProblemData)Problem.ProblemData.Clone(), model);145 var solution = new RandomForestRegressionSolution(model, (IRegressionProblemData)Problem.ProblemData.Clone()); 146 146 Results.Add(new Result(RandomForestRegressionModelResultName, "The random forest regression solution.", solution)); 147 147 } … … 153 153 var model = CreateRandomForestRegressionModel(problemData, nTrees, r, m, seed, 154 154 out rmsError, out avgRelError, out outOfBagRmsError, out outOfBagAvgRelError); 155 return new RandomForestRegressionSolution( (IRegressionProblemData)problemData.Clone(), model);155 return new RandomForestRegressionSolution(model, (IRegressionProblemData)problemData.Clone()); 156 156 } 157 157 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegressionSolution.cs
r12009 r14027 43 43 : base(original, cloner) { 44 44 } 45 public RandomForestRegressionSolution(IR egressionProblemData problemData, IRandomForestModel randomForestModel)45 public RandomForestRegressionSolution(IRandomForestModel randomForestModel, IRegressionProblemData problemData) 46 46 : base(randomForestModel, problemData) { 47 47 }
Note: See TracChangeset
for help on using the changeset viewer.