Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/11 11:01:08 (13 years ago)
Author:
mkommend
Message:

#1479: Updated grammar editor branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r6618 r6647  
    3232    private const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)";
    3333    private const string TestMeanSquaredErrorResultName = "Mean squared error (test)";
     34    private const string TrainingMeanAbsoluteErrorResultName = "Mean absolute error (training)";
     35    private const string TestMeanAbsoluteErrorResultName = "Mean absolute error (test)";
    3436    private const string TrainingSquaredCorrelationResultName = "Pearson's R² (training)";
    3537    private const string TestSquaredCorrelationResultName = "Pearson's R² (test)";
     
    6264      get { return ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value; }
    6365      private set { ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value = value; }
     66    }
     67    public double TrainingMeanAbsoluteError {
     68      get { return ((DoubleValue)this[TrainingMeanAbsoluteErrorResultName].Value).Value; }
     69      private set { ((DoubleValue)this[TrainingMeanAbsoluteErrorResultName].Value).Value = value; }
     70    }
     71    public double TestMeanAbsoluteError {
     72      get { return ((DoubleValue)this[TestMeanAbsoluteErrorResultName].Value).Value; }
     73      private set { ((DoubleValue)this[TestMeanAbsoluteErrorResultName].Value).Value = value; }
    6474    }
    6575    public double TrainingRSquared {
     
    98108      Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue()));
    99109      Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue()));
     110      Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
     111      Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue()));
    100112      Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    101113      Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
     
    104116      Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue()));
    105117      Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue()));
     118    }
     119
     120    [StorableHook(HookType.AfterDeserialization)]
     121    private void AfterDeserialization() {
     122      // BackwardsCompatibility3.4
     123
     124      #region Backwards compatible code, remove with 3.5
     125
     126      if (!ContainsKey(TrainingMeanAbsoluteErrorResultName)) {
     127        OnlineCalculatorError errorState;
     128        Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
     129        double trainingMAE = OnlineMeanSquaredErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes), out errorState);
     130        TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
     131      }
     132
     133      if (!ContainsKey(TestMeanAbsoluteErrorResultName)) {
     134        OnlineCalculatorError errorState;
     135        Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue()));
     136        double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(EstimatedTestValues, ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes), out errorState);
     137        TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
     138      }
     139      #endregion
    106140    }
    107141
     
    117151      double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    118152      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
     153
     154      double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     155      TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
     156      double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     157      TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    119158
    120159      double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
Note: See TracChangeset for help on using the changeset viewer.