Changeset 17045 for branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs
- Timestamp:
- 06/27/19 15:46:20 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2952_RF-ModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs
r16565 r17045 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 24 using System.Threading; 25 using HEAL.Attic; 23 26 using HeuristicLab.Common; 24 27 using HeuristicLab.Core; … … 26 29 using HeuristicLab.Optimization; 27 30 using HeuristicLab.Parameters; 28 using HEAL.Attic;29 31 using HeuristicLab.Problems.DataAnalysis; 30 32 … … 144 146 145 147 if (CreateSolution) { 146 var solution = new RandomForestRegressionSolution(model, (IRegressionProblemData)Problem.ProblemData.Clone());148 var solution = model.CreateRegressionSolution(Problem.ProblemData); 147 149 Results.Add(new Result(RandomForestRegressionModelResultName, "The random forest regression solution.", solution)); 148 150 } 149 151 } 152 150 153 151 154 // keep for compatibility with old API … … 157 160 } 158 161 159 public static RandomForestModel CreateRandomForestRegressionModel(IRegressionProblemData problemData, int nTrees, 160 double r, double m, int seed, 161 out double rmsError, out double avgRelError, out double outOfBagRmsError, out double outOfBagAvgRelError) { 162 return RandomForestModel.CreateRegressionModel(problemData, nTrees, r, m, seed, 163 rmsError: out rmsError, avgRelError: out avgRelError, outOfBagRmsError: out outOfBagRmsError, outOfBagAvgRelError: out outOfBagAvgRelError); 162 public static RandomForestModelFull CreateRandomForestRegressionModel(IRegressionProblemData problemData, int nTrees, 163 double r, double m, int seed, 164 out double rmsError, out double avgRelError, out double outOfBagRmsError, out double outOfBagAvgRelError) { 165 return CreateRandomForestRegressionModel(problemData, problemData.TrainingIndices, nTrees, r, m, seed, out rmsError, out avgRelError, out outOfBagRmsError, out outOfBagAvgRelError); 166 } 167 168 public static RandomForestModelFull CreateRandomForestRegressionModel(IRegressionProblemData problemData, IEnumerable<int> trainingIndices, int nTrees, double r, double m, int seed, 169 out double rmsError, out double avgRelError, out double outOfBagRmsError, out double outOfBagAvgRelError) { 170 171 var variables = problemData.AllowedInputVariables.Concat(new string[] { problemData.TargetVariable }); 172 double[,] inputMatrix = problemData.Dataset.ToArray(variables, trainingIndices); 173 174 alglib.dfreport rep; 175 var dForest = RandomForestUtil.CreateRandomForestModel(seed, inputMatrix, nTrees, r, m, 1, out rep); 176 177 rmsError = rep.rmserror; 178 outOfBagRmsError = rep.oobrmserror; 179 avgRelError = rep.avgrelerror; 180 outOfBagAvgRelError = rep.oobavgrelerror; 181 182 return new RandomForestModelFull(dForest, problemData.TargetVariable, problemData.AllowedInputVariables); 183 184 //return RandomForestModel.CreateRegressionModel(problemData, nTrees, r, m, seed, 185 //rmsError: out rmsError, avgRelError: out avgRelError, outOfBagRmsError: out outOfBagRmsError, outOfBagAvgRelError: out outOfBagAvgRelError); 164 186 } 165 187
Note: See TracChangeset
for help on using the changeset viewer.