- Timestamp:
- 06/30/12 17:05:23 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs
r8152 r8167 37 37 [Creatable("Data Analysis - Ensembles")] 38 38 public sealed class RegressionEnsembleSolution : RegressionSolution, IRegressionEnsembleSolution { 39 private readonly Dictionary<int, double> trainingEstimatedValuesCache = new Dictionary<int, double>(); 40 private readonly Dictionary<int, double> testEstimatedValuesCache = new Dictionary<int, double>(); 41 private readonly Dictionary<int, double> estimatedValuesCache = new Dictionary<int, double>(); 39 private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>(); 40 private readonly Dictionary<int, double> testEvaluationCache = new Dictionary<int, double>(); 42 41 43 42 public new IRegressionEnsembleModel Model { … … 158 157 get { 159 158 var rows = ProblemData.TrainingIndices; 160 var rowsToEvaluate = rows.Except(trainingE stimatedValuesCache.Keys);159 var rowsToEvaluate = rows.Except(trainingEvaluationCache.Keys); 161 160 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 162 161 var valuesEnumerator = GetEstimatedValues(rowsToEvaluate, (r, m) => RowIsTrainingForModel(r, m) && !RowIsTestForModel(r, m)).GetEnumerator(); 163 162 164 163 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 165 trainingE stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);164 trainingEvaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 166 165 } 167 166 168 return rows.Select(row => trainingE stimatedValuesCache[row]);167 return rows.Select(row => trainingEvaluationCache[row]); 169 168 } 170 169 } … … 173 172 get { 174 173 var rows = ProblemData.TestIndices; 175 var rowsToEvaluate = rows.Except(testE stimatedValuesCache.Keys);174 var rowsToEvaluate = rows.Except(testEvaluationCache.Keys); 176 175 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 177 176 var valuesEnumerator = GetEstimatedValues(rowsToEvaluate, RowIsTestForModel).GetEnumerator(); 178 177 179 178 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 180 testE stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);179 testEvaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 181 180 } 182 181 183 return rows.Select(row => testE stimatedValuesCache[row]);182 return rows.Select(row => testEvaluationCache[row]); 184 183 } 185 184 } … … 213 212 214 213 public override IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) { 215 var rowsToEvaluate = rows.Except(e stimatedValuesCache.Keys);214 var rowsToEvaluate = rows.Except(evaluationCache.Keys); 216 215 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 217 216 var valuesEnumerator = (from xs in GetEstimatedValueVectors(ProblemData.Dataset, rowsToEvaluate) … … 220 219 221 220 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 222 e stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);223 } 224 225 return rows.Select(row => e stimatedValuesCache[row]);221 evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 222 } 223 224 return rows.Select(row => evaluationCache[row]); 226 225 } 227 226 … … 244 243 245 244 protected override void OnProblemDataChanged() { 246 trainingE stimatedValuesCache.Clear();247 testE stimatedValuesCache.Clear();248 e stimatedValuesCache.Clear();245 trainingEvaluationCache.Clear(); 246 testEvaluationCache.Clear(); 247 evaluationCache.Clear(); 249 248 IRegressionProblemData problemData = new RegressionProblemData(ProblemData.Dataset, 250 249 ProblemData.AllowedInputVariables, … … 276 275 regressionSolutions.AddRange(solutions); 277 276 278 trainingE stimatedValuesCache.Clear();279 testE stimatedValuesCache.Clear();280 e stimatedValuesCache.Clear();277 trainingEvaluationCache.Clear(); 278 testEvaluationCache.Clear(); 279 evaluationCache.Clear(); 281 280 } 282 281 public void RemoveRegressionSolutions(IEnumerable<IRegressionSolution> solutions) { 283 282 regressionSolutions.RemoveRange(solutions); 284 283 285 trainingE stimatedValuesCache.Clear();286 testE stimatedValuesCache.Clear();287 e stimatedValuesCache.Clear();284 trainingEvaluationCache.Clear(); 285 testEvaluationCache.Clear(); 286 evaluationCache.Clear(); 288 287 } 289 288 … … 308 307 testPartitions[solution.Model] = solution.ProblemData.TestPartition; 309 308 310 trainingE stimatedValuesCache.Clear();311 testE stimatedValuesCache.Clear();312 e stimatedValuesCache.Clear();309 trainingEvaluationCache.Clear(); 310 testEvaluationCache.Clear(); 311 evaluationCache.Clear(); 313 312 } 314 313 … … 319 318 testPartitions.Remove(solution.Model); 320 319 321 trainingE stimatedValuesCache.Clear();322 testE stimatedValuesCache.Clear();323 e stimatedValuesCache.Clear();320 trainingEvaluationCache.Clear(); 321 testEvaluationCache.Clear(); 322 evaluationCache.Clear(); 324 323 } 325 324 }
Note: See TracChangeset
for help on using the changeset viewer.