Changeset 8167
- Timestamp:
- 06/30/12 17:05:23 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
- Files:
-
- 2 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 } -
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.