Changeset 8167 for trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification
- Timestamp:
- 06/30/12 17:05:23 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs
r8153 r8167 37 37 [Creatable("Data Analysis - Ensembles")] 38 38 public sealed class ClassificationEnsembleSolution : ClassificationSolution, IClassificationEnsembleSolution { 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 IClassificationEnsembleModel Model { … … 153 152 get { 154 153 var rows = ProblemData.TrainingIndices; 155 var rowsToEvaluate = rows.Except(trainingE stimatedValuesCache.Keys);154 var rowsToEvaluate = rows.Except(trainingEvaluationCache.Keys); 156 155 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 157 156 var valuesEnumerator = GetEstimatedValues(rowsToEvaluate, (r, m) => RowIsTrainingForModel(r, m) && !RowIsTestForModel(r, m)).GetEnumerator(); 158 157 159 158 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 160 trainingE stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);159 trainingEvaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 161 160 } 162 161 163 return rows.Select(row => trainingE stimatedValuesCache[row]);162 return rows.Select(row => trainingEvaluationCache[row]); 164 163 } 165 164 } … … 168 167 get { 169 168 var rows = ProblemData.TestIndices; 170 var rowsToEvaluate = rows.Except(testE stimatedValuesCache.Keys);169 var rowsToEvaluate = rows.Except(testEvaluationCache.Keys); 171 170 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 172 171 var valuesEnumerator = GetEstimatedValues(rowsToEvaluate, RowIsTestForModel).GetEnumerator(); 173 172 174 173 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 175 testE stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);174 testEvaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 176 175 } 177 176 178 return rows.Select(row => testE stimatedValuesCache[row]);177 return rows.Select(row => testEvaluationCache[row]); 179 178 } 180 179 } … … 208 207 209 208 public override IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows) { 210 var rowsToEvaluate = rows.Except(e stimatedValuesCache.Keys);209 var rowsToEvaluate = rows.Except(evaluationCache.Keys); 211 210 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 212 211 var valuesEnumerator = (from xs in GetEstimatedClassValueVectors(ProblemData.Dataset, rowsToEvaluate) … … 215 214 216 215 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 217 e stimatedValuesCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);218 } 219 220 return rows.Select(row => e stimatedValuesCache[row]);216 evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 217 } 218 219 return rows.Select(row => evaluationCache[row]); 221 220 } 222 221 … … 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 250 249 IClassificationProblemData problemData = new ClassificationProblemData(ProblemData.Dataset, … … 277 276 classificationSolutions.AddRange(solutions); 278 277 279 trainingE stimatedValuesCache.Clear();280 testE stimatedValuesCache.Clear();281 e stimatedValuesCache.Clear();278 trainingEvaluationCache.Clear(); 279 testEvaluationCache.Clear(); 280 evaluationCache.Clear(); 282 281 } 283 282 public void RemoveClassificationSolutions(IEnumerable<IClassificationSolution> solutions) { 284 283 classificationSolutions.RemoveRange(solutions); 285 284 286 trainingE stimatedValuesCache.Clear();287 testE stimatedValuesCache.Clear();288 e stimatedValuesCache.Clear();285 trainingEvaluationCache.Clear(); 286 testEvaluationCache.Clear(); 287 evaluationCache.Clear(); 289 288 } 290 289 … … 309 308 testPartitions[solution.Model] = solution.ProblemData.TestPartition; 310 309 311 trainingE stimatedValuesCache.Clear();312 testE stimatedValuesCache.Clear();313 e stimatedValuesCache.Clear();310 trainingEvaluationCache.Clear(); 311 testEvaluationCache.Clear(); 312 evaluationCache.Clear(); 314 313 } 315 314 … … 320 319 testPartitions.Remove(solution.Model); 321 320 322 trainingE stimatedValuesCache.Clear();323 testE stimatedValuesCache.Clear();324 e stimatedValuesCache.Clear();321 trainingEvaluationCache.Clear(); 322 testEvaluationCache.Clear(); 323 evaluationCache.Clear(); 325 324 } 326 325 }
Note: See TracChangeset
for help on using the changeset viewer.