Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6411


Ignore:
Timestamp:
06/14/11 14:00:19 (14 years ago)
Author:
mkommend
Message:

#1506: Restructured calculation of results in IDataAnalysisSolutions and fixed bug in SymbolicDiscriminantClassisificationEstimatedValuesView.

Location:
trunk/sources
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs

    r6256 r6411  
    5151    protected override void UpdateModel(ISymbolicExpressionTree tree) {
    5252      Content.Model = new SymbolicDiscriminantFunctionClassificationModel(tree, Content.Model.Interpreter);
    53       Content.SetClassDistibutionCutPointThresholds();
    5453    }
    5554
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolution.cs

    r5809 r6411  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
    2624using HeuristicLab.Data;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    29 using HeuristicLab.Parameters;
     25using HeuristicLab.Optimization;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    32 using System;
    3327
    3428namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    6963      Add(new Result(ModelLengthResultName, "Length of the symbolic classification model.", new IntValue()));
    7064      Add(new Result(ModelDepthResultName, "Depth of the symbolic classification model.", new IntValue()));
    71       RecalculateResults();
     65      CalculateResults();
    7266    }
    7367
     
    7670    }
    7771
    78     protected override void OnModelChanged(EventArgs e) {
    79       base.OnModelChanged(e);
    80       RecalculateResults();
     72    protected override void RecalculateResults() {
     73      base.RecalculateResults();
     74      CalculateResults();
    8175    }
    8276
    83     private new void RecalculateResults() {
     77    private void CalculateResults() {
    8478      ModelLength = Model.SymbolicExpressionTree.Length;
    8579      ModelDepth = Model.SymbolicExpressionTree.Depth;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolution.cs

    r5975 r6411  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    6766      Add(new Result(ModelLengthResultName, "Length of the symbolic classification model.", new IntValue()));
    6867      Add(new Result(ModelDepthResultName, "Depth of the symbolic classification model.", new IntValue()));
    69       RecalculateResults();
     68      CalculateResults();
    7069    }
    7170
     
    7473    }
    7574
    76     protected override void OnModelChanged(EventArgs e) {
    77       base.OnModelChanged(e);
    78       RecalculateResults();
     75    protected override void RecalculateResults() {
     76      base.RecalculateResults();
     77      CalculateResults();
    7978    }
    8079
    81     private new void RecalculateResults() {
     80    private void CalculateResults() {
    8281      ModelLength = Model.SymbolicExpressionTree.Length;
    8382      ModelDepth = Model.SymbolicExpressionTree.Depth;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

    r6233 r6411  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    6362      Add(new Result(ModelLengthResultName, "Length of the symbolic regression model.", new IntValue()));
    6463      Add(new Result(ModelDepthResultName, "Depth of the symbolic regression model.", new IntValue()));
    65       RecalculateResults();
     64      CalculateResults();
    6665    }
    6766
     
    7069    }
    7170
    72     protected override void OnModelChanged(EventArgs e) {
    73       base.OnModelChanged(e);
    74       RecalculateResults();
     71    protected override void RecalculateResults() {
     72      base.RecalculateResults();
     73      CalculateResults();
    7574    }
    7675
    77     private void RecalculateResults() {
     76    private void CalculateResults() {
    7877      ModelLength = Model.SymbolicExpressionTree.Length;
    7978      ModelDepth = Model.SymbolicExpressionTree.Depth;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionEstimatedClassValuesView.cs

    r6255 r6411  
    8686        StringMatrix matrix = null;
    8787        if (Content != null) {
    88           string[,] values = new string[Content.ProblemData.Dataset.Rows, 5];
     88          string[,] values = new string[Content.ProblemData.Dataset.Rows, 4];
    8989
    9090          double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs

    r6184 r6411  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    6665      Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue()));
    6766      Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue()));
    68       RecalculateResults();
     67      CalculateResults();
    6968    }
    7069
     
    7372    }
    7473
    75     protected override void OnProblemDataChanged(EventArgs e) {
    76       base.OnProblemDataChanged(e);
    77       RecalculateResults();
     74    protected override void RecalculateResults() {
     75      CalculateResults();
    7876    }
    7977
    80     protected override void OnModelChanged(EventArgs e) {
    81       base.OnModelChanged(e);
    82       RecalculateResults();
    83     }
    84 
    85     protected void RecalculateResults() {
     78    private void CalculateResults() {
    8679      double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values
    8780      IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r5942 r6411  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827using HeuristicLab.Data;
    2928using HeuristicLab.Optimization;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis {
     
    8989      Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    9090      Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
     91      SetAccuracyMaximizingThresholds();
     92
     93      //mkommend: important to recalculate accuracy because during the calculation before no thresholds were present     
     94      base.RecalculateResults();
     95      CalculateResults();
    9196      RegisterEventHandler();
    92       SetAccuracyMaximizingThresholds();
    93       RecalculateResults();
    9497    }
    9598
     
    99102    }
    100103
    101     protected new void RecalculateResults() {
     104    protected override void OnModelChanged(EventArgs e) {
     105      DeregisterEventHandler();
     106      SetAccuracyMaximizingThresholds();
     107      RegisterEventHandler();
     108      base.OnModelChanged(e);
     109    }
     110
     111    protected override void RecalculateResults() {
     112      base.RecalculateResults();
     113      CalculateResults();
     114    }
     115
     116    private void CalculateResults() {
    102117      double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values
    103118      IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
     
    119134    private void RegisterEventHandler() {
    120135      Model.ThresholdsChanged += new EventHandler(Model_ThresholdsChanged);
     136    }
     137    private void DeregisterEventHandler() {
     138      Model.ThresholdsChanged -= new EventHandler(Model_ThresholdsChanged);
    121139    }
    122140    private void Model_ThresholdsChanged(object sender, EventArgs e) {
     
    142160    }
    143161
    144     protected override void OnModelChanged(EventArgs e) {
    145       base.OnModelChanged(e);
    146       SetAccuracyMaximizingThresholds();
    147       RecalculateResults();
    148     }
    149 
    150     protected override void OnProblemDataChanged(EventArgs e) {
    151       base.OnProblemDataChanged(e);
    152       SetAccuracyMaximizingThresholds();
    153       RecalculateResults();
    154     }
    155162    protected virtual void OnModelThresholdsChanged(EventArgs e) {
    156       base.OnModelChanged(e);
    157163      RecalculateResults();
    158164    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringSolution.cs

    r6184 r6411  
    4545    }
    4646
     47    protected override void RecalculateResults() {
     48    }
     49
    4750    #region IClusteringSolution Members
    4851
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs

    r5914 r6411  
    8686    }
    8787
     88    protected abstract void RecalculateResults();
     89
    8890    private void ProblemData_Changed(object sender, EventArgs e) {
    8991      OnProblemDataChanged(e);
     
    9294    public event EventHandler ModelChanged;
    9395    protected virtual void OnModelChanged(EventArgs e) {
     96      RecalculateResults();
    9497      var listeners = ModelChanged;
    9598      if (listeners != null) listeners(this, e);
     
    98101    public event EventHandler ProblemDataChanged;
    99102    protected virtual void OnProblemDataChanged(EventArgs e) {
     103      RecalculateResults();
    100104      var listeners = ProblemDataChanged;
    101105      if (listeners != null) listeners(this, e);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs

    r6238 r6411  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    110109      Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue()));
    111110
    112       RecalculateResults();
     111      CalculateResults();
    113112    }
    114113
     
    117116    }
    118117
    119     protected override void OnProblemDataChanged(EventArgs e) {
    120       base.OnProblemDataChanged(e);
    121       RecalculateResults();
    122     }
    123     protected override void OnModelChanged(EventArgs e) {
    124       base.OnModelChanged(e);
    125       RecalculateResults();
     118    protected override void RecalculateResults() {
     119      CalculateResults();
    126120    }
    127121
    128     protected void RecalculateResults() {
     122    private void CalculateResults() {
    129123      double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values
    130124      IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
Note: See TracChangeset for help on using the changeset viewer.