Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/11 16:34:31 (14 years ago)
Author:
gkronber
Message:

#1418 Implemented interactive simplifier views for symbolic classification and regression.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationSolution.cs

    r5649 r5717  
    3939    private const string TrainingAccuracyResultName = "Accuracy (training)";
    4040    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
    4162    [StorableConstructor]
    4263    protected ClassificationSolution(bool deserializing) : base(deserializing) { }
     
    4667    public ClassificationSolution(IClassificationModel model, IClassificationProblemData problemData)
    4768      : 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() {
    4885      double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values
    4986      IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
     
    5491      double testAccuracy = OnlineAccuracyEvaluator.Calculate(estimatedTestClassValues, originalTestClassValues);
    5592
    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;
    6895    }
    6996
     
    89116      return Model.GetEstimatedClassValues(ProblemData.Dataset, rows);
    90117    }
    91     #endregion
    92118  }
    93119}
Note: See TracChangeset for help on using the changeset viewer.