Changeset 12694 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest
- Timestamp:
- 07/09/15 13:07:30 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassification.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; … … 36 33 /// </summary> 37 34 [Item("Random Forest Classification", "Random forest classification data analysis algorithm (wrapper for ALGLIB).")] 38 [Creatable( "Data Analysis")]35 [Creatable(CreatableAttribute.Categories.DataAnalysisClassification, Priority = 120)] 39 36 [StorableClass] 40 37 public sealed class RandomForestClassification : FixedDataAnalysisAlgorithm<IClassificationProblem> { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestClassificationSolution.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 76 76 // we assume that the trees array (double[]) is immutable in alglib 77 77 randomForest.innerobj.trees = original.randomForest.innerobj.trees; 78 78 79 79 // allowedInputVariables is immutable so we don't need to clone 80 80 allowedInputVariables = original.allowedInputVariables; … … 129 129 } 130 130 131 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {131 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 132 132 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows); 133 133 AssertInputMatrix(inputData); … … 147 147 } 148 148 149 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {149 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 150 150 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows); 151 151 AssertInputMatrix(inputData); … … 188 188 189 189 public static RandomForestModel CreateRegressionModel(IRegressionProblemData problemData, int nTrees, double r, double m, int seed, 190 out double rmsError, out double avgRelError, out double outOfBagAvgRelError, out double outOfBagRmsError) { 191 190 out double rmsError, out double outOfBagRmsError, out double avgRelError, out double outOfBagAvgRelError) { 191 return CreateRegressionModel(problemData, problemData.TrainingIndices, nTrees, r, m, seed, out rmsError, out avgRelError, out outOfBagAvgRelError, out outOfBagRmsError); 192 } 193 194 public static RandomForestModel CreateRegressionModel(IRegressionProblemData problemData, IEnumerable<int> trainingIndices, int nTrees, double r, double m, int seed, 195 out double rmsError, out double outOfBagRmsError, out double avgRelError, out double outOfBagAvgRelError) { 192 196 var variables = problemData.AllowedInputVariables.Concat(new string[] { problemData.TargetVariable }); 193 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(problemData.Dataset, variables, problemData.TrainingIndices);197 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(problemData.Dataset, variables, trainingIndices); 194 198 195 199 alglib.dfreport rep; … … 201 205 outOfBagRmsError = rep.oobrmserror; 202 206 203 return new RandomForestModel(dForest, 204 seed, problemData, 205 nTrees, r, m); 207 return new RandomForestModel(dForest, seed, problemData, nTrees, r, m); 206 208 } 207 209 208 210 public static RandomForestModel CreateClassificationModel(IClassificationProblemData problemData, int nTrees, double r, double m, int seed, 209 211 out double rmsError, out double outOfBagRmsError, out double relClassificationError, out double outOfBagRelClassificationError) { 212 return CreateClassificationModel(problemData, problemData.TrainingIndices, nTrees, r, m, seed, out rmsError, out outOfBagRmsError, out relClassificationError, out outOfBagRelClassificationError); 213 } 214 215 public static RandomForestModel CreateClassificationModel(IClassificationProblemData problemData, IEnumerable<int> trainingIndices, int nTrees, double r, double m, int seed, 216 out double rmsError, out double outOfBagRmsError, out double relClassificationError, out double outOfBagRelClassificationError) { 210 217 211 218 var variables = problemData.AllowedInputVariables.Concat(new string[] { problemData.TargetVariable }); 212 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(problemData.Dataset, variables, problemData.TrainingIndices);219 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(problemData.Dataset, variables, trainingIndices); 213 220 214 221 var classValues = problemData.ClassValues.ToArray(); … … 235 242 outOfBagRelClassificationError = rep.oobrelclserror; 236 243 237 return new RandomForestModel(dForest, 238 seed, problemData, 239 nTrees, r, m, classValues); 244 return new RandomForestModel(dForest, seed, problemData, nTrees, r, m, classValues); 240 245 } 241 246 … … 264 269 265 270 private static void AssertInputMatrix(double[,] inputMatrix) { 266 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))271 if (inputMatrix.Cast<double>().Any(x => Double.IsNaN(x) || Double.IsInfinity(x))) 267 272 throw new NotSupportedException("Random forest modeling does not support NaN or infinity values in the input dataset."); 268 273 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegression.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; … … 36 33 /// </summary> 37 34 [Item("Random Forest Regression", "Random forest regression data analysis algorithm (wrapper for ALGLIB).")] 38 [Creatable( "Data Analysis")]35 [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 120)] 39 36 [StorableClass] 40 37 public sealed class RandomForestRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegressionSolution.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.