Changeset 13698 for trunk/sources/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 03/14/16 17:49:05 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs
r13697 r13698 73 73 74 74 #region IRegressionEnsembleModel Members 75 76 75 public void Add(IRegressionModel model) { 77 76 models.Add(model); … … 106 105 } 107 106 } 108 109 107 #endregion 110 108 … … 117 115 118 116 public RegressionEnsembleSolution CreateRegressionSolution(IRegressionProblemData problemData) { 119 return new RegressionEnsembleSolution(this .Models, new RegressionEnsembleProblemData(problemData));117 return new RegressionEnsembleSolution(this, new RegressionEnsembleProblemData(problemData)); 120 118 } 121 119 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs
r13697 r13698 93 93 } 94 94 95 evaluationCache = new Dictionary<int, double>(original.ProblemData.Dataset.Rows); 95 96 trainingEvaluationCache = new Dictionary<int, double>(original.ProblemData.TrainingIndices.Count()); 96 97 testEvaluationCache = new Dictionary<int, double>(original.ProblemData.TestIndices.Count()); … … 110 111 111 112 public RegressionEnsembleSolution(IRegressionProblemData problemData) 112 : this(Enumerable.Empty<IRegressionModel>(), problemData) { 113 } 114 115 public RegressionEnsembleSolution(IEnumerable<IRegressionModel> models, IRegressionProblemData problemData) 116 : this(models, problemData, 117 models.Select(m => (IntRange)problemData.TrainingPartition.Clone()), 118 models.Select(m => (IntRange)problemData.TestPartition.Clone()) 119 ) { } 120 121 public RegressionEnsembleSolution(IEnumerable<IRegressionModel> models, IRegressionProblemData problemData, IEnumerable<IntRange> trainingPartitions, IEnumerable<IntRange> testPartitions) 122 : base(new RegressionEnsembleModel(Enumerable.Empty<IRegressionModel>()), new RegressionEnsembleProblemData(problemData)) { 123 this.trainingPartitions = new Dictionary<IRegressionModel, IntRange>(); 124 this.testPartitions = new Dictionary<IRegressionModel, IntRange>(); 125 this.regressionSolutions = new ItemCollection<IRegressionSolution>(); 126 127 List<IRegressionSolution> solutions = new List<IRegressionSolution>(); 128 var modelEnumerator = models.GetEnumerator(); 129 var trainingPartitionEnumerator = trainingPartitions.GetEnumerator(); 130 var testPartitionEnumerator = testPartitions.GetEnumerator(); 131 132 while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) { 133 var p = (IRegressionProblemData)problemData.Clone(); 134 p.TrainingPartition.Start = trainingPartitionEnumerator.Current.Start; 135 p.TrainingPartition.End = trainingPartitionEnumerator.Current.End; 136 p.TestPartition.Start = testPartitionEnumerator.Current.Start; 137 p.TestPartition.End = testPartitionEnumerator.Current.End; 138 139 solutions.Add(modelEnumerator.Current.CreateRegressionSolution(p)); 140 } 141 if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) { 142 throw new ArgumentException(); 143 } 144 113 : this(new RegressionEnsembleModel(), problemData) { 114 } 115 116 public RegressionEnsembleSolution(IRegressionEnsembleModel model, IRegressionProblemData problemData) 117 : base(model, new RegressionEnsembleProblemData(problemData)) { 118 trainingPartitions = new Dictionary<IRegressionModel, IntRange>(); 119 testPartitions = new Dictionary<IRegressionModel, IntRange>(); 120 regressionSolutions = new ItemCollection<IRegressionSolution>(); 121 122 evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows); 145 123 trainingEvaluationCache = new Dictionary<int, double>(problemData.TrainingIndices.Count()); 146 124 testEvaluationCache = new Dictionary<int, double>(problemData.TestIndices.Count()); 147 125 148 126 RegisterRegressionSolutionsEventHandler(); 127 var solutions = model.Models.Select(m => m.CreateRegressionSolution((IRegressionProblemData)problemData.Clone())); 149 128 regressionSolutions.AddRange(solutions); 150 129 } 130 151 131 152 132 public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset
for help on using the changeset viewer.