Changeset 5717 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationSolution.cs
- Timestamp:
- 03/16/11 16:34:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationSolution.cs
r5649 r5717 39 39 private const string TrainingAccuracyResultName = "Accuracy (training)"; 40 40 private const string TestAccuracyResultName = "Accuracy (test)"; 41 42 public new IClassificationModel Model { 43 get { return (IClassificationModel)base.Model; } 44 protected set { base.Model = value; } 45 } 46 47 public new IClassificationProblemData ProblemData { 48 get { return (IClassificationProblemData)base.ProblemData; } 49 protected set { base.ProblemData = value; } 50 } 51 52 public double TrainingAccuracy { 53 get { return ((DoubleValue)this[TrainingAccuracyResultName].Value).Value; } 54 private set { ((DoubleValue)this[TrainingAccuracyResultName].Value).Value = value; } 55 } 56 57 public double TestAccuracy { 58 get { return ((DoubleValue)this[TestAccuracyResultName].Value).Value; } 59 private set { ((DoubleValue)this[TestAccuracyResultName].Value).Value = value; } 60 } 61 41 62 [StorableConstructor] 42 63 protected ClassificationSolution(bool deserializing) : base(deserializing) { } … … 46 67 public ClassificationSolution(IClassificationModel model, IClassificationProblemData problemData) 47 68 : base(model, problemData) { 69 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue())); 70 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue())); 71 RecalculateResults(); 72 } 73 74 protected override void OnProblemDataChanged(EventArgs e) { 75 base.OnProblemDataChanged(e); 76 RecalculateResults(); 77 } 78 79 protected override void OnModelChanged(EventArgs e) { 80 base.OnModelChanged(e); 81 RecalculateResults(); 82 } 83 84 private void RecalculateResults() { 48 85 double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values 49 86 IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); … … 54 91 double testAccuracy = OnlineAccuracyEvaluator.Calculate(estimatedTestClassValues, originalTestClassValues); 55 92 56 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue(trainingAccuracy))); 57 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue(testAccuracy))); 58 } 59 60 #region IClassificationSolution Members 61 62 public new IClassificationModel Model { 63 get { return (IClassificationModel)base.Model; } 64 } 65 66 public new IClassificationProblemData ProblemData { 67 get { return (IClassificationProblemData)base.ProblemData; } 93 TrainingAccuracy = trainingAccuracy; 94 TestAccuracy = testAccuracy; 68 95 } 69 96 … … 89 116 return Model.GetEstimatedClassValues(ProblemData.Dataset, rows); 90 117 } 91 #endregion92 118 } 93 119 }
Note: See TracChangeset
for help on using the changeset viewer.