Changeset 6647 for branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs
- Timestamp:
- 08/09/11 11:01:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs
r6618 r6647 32 32 private const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)"; 33 33 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)"; 34 36 private const string TrainingSquaredCorrelationResultName = "Pearson's R² (training)"; 35 37 private const string TestSquaredCorrelationResultName = "Pearson's R² (test)"; … … 62 64 get { return ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value; } 63 65 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; } 64 74 } 65 75 public double TrainingRSquared { … … 98 108 Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue())); 99 109 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())); 100 112 Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 101 113 Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); … … 104 116 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue())); 105 117 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 106 140 } 107 141 … … 117 151 double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState); 118 152 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; 119 158 120 159 double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
Note: See TracChangeset
for help on using the changeset viewer.