Changeset 6606 for trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
- Timestamp:
- 07/28/11 13:57:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r6589 r6606 31 31 [StorableClass] 32 32 public abstract class ClassificationSolution : ClassificationSolutionBase { 33 protected readonly Dictionary<int, double> evaluationCache; 34 33 35 [StorableConstructor] 34 protected ClassificationSolution(bool deserializing) : base(deserializing) { } 36 protected ClassificationSolution(bool deserializing) 37 : base(deserializing) { 38 evaluationCache = new Dictionary<int, double>(); 39 } 35 40 protected ClassificationSolution(ClassificationSolution original, Cloner cloner) 36 41 : base(original, cloner) { 42 evaluationCache = new Dictionary<int, double>(original.evaluationCache); 37 43 } 38 44 public ClassificationSolution(IClassificationModel model, IClassificationProblemData problemData) 39 45 : base(model, problemData) { 46 evaluationCache = new Dictionary<int, double>(); 40 47 } 41 48 … … 51 58 52 59 public override IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows) { 53 return Model.GetEstimatedClassValues(ProblemData.Dataset, rows); 60 var rowsToEvaluate = rows.Except(evaluationCache.Keys); 61 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 62 var valuesEnumerator = Model.GetEstimatedClassValues(ProblemData.Dataset, rowsToEvaluate).GetEnumerator(); 63 64 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 65 evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 66 } 67 68 return rows.Select(row => evaluationCache[row]); 69 } 70 71 protected override void OnProblemDataChanged() { 72 evaluationCache.Clear(); 73 base.OnProblemDataChanged(); 74 } 75 76 protected override void OnModelChanged() { 77 evaluationCache.Clear(); 78 base.OnModelChanged(); 54 79 } 55 80 }
Note: See TracChangeset
for help on using the changeset viewer.