Changeset 3710 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs
- Timestamp:
- 05/07/10 21:10:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs
r3681 r3710 34 34 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols; 35 35 using HeuristicLab.Problems.DataAnalysis; 36 using HeuristicLab.Problems.DataAnalysis.Evaluators; 36 37 37 38 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers { … … 48 49 private const string BestSolutionQualityParameterName = "BestSolutionQuality"; 49 50 private const string ResultsParameterName = "Results"; 50 51 private const string BestSolutionResultName = "Best Solution (on validiation set)"; 52 private const string BestSolutionInputvariableCountResultName = "Variables Used by Best Solution"; 51 private const string BestSolutionResultName = "Best solution (on validiation set)"; 52 private const string BestSolutionInputvariableCountResultName = "Variables used by best solution"; 53 private const string BestSolutionTrainingRSquared = "Best solution R² (training)"; 54 private const string BestSolutionTestRSquared = "Best solution R² (test)"; 55 private const string BestSolutionTrainingMse = "Best solution mean squared error (training)"; 56 private const string BestSolutionTestMse = "Best solution mean squared error (test)"; 57 private const string BestSolutionTrainingRelativeError = "Best solution average relative error (training)"; 58 private const string BestSolutionTestRelativeError = "Best solution average relative error (test)"; 53 59 54 60 public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { … … 112 118 results.Add(new Result(BestSolutionResultName, solution)); 113 119 results.Add(new Result(BestSolutionInputvariableCountResultName, new IntValue(model.InputVariables.Count()))); 120 #region calculate R2,MSE,Rel Error 121 double[] trainingValues = problemData.Dataset.GetVariableValues( 122 problemData.TargetVariable.Value, 123 problemData.TrainingSamplesStart.Value, 124 problemData.TrainingSamplesEnd.Value); 125 double[] testValues = problemData.Dataset.GetVariableValues( 126 problemData.TargetVariable.Value, 127 problemData.TestSamplesStart.Value, 128 problemData.TestSamplesEnd.Value); 129 double trainingR2 = SimpleRSquaredEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 130 double testR2 = SimpleRSquaredEvaluator.Calculate(testValues, solution.EstimatedTestValues); 131 double trainingMse = SimpleMSEEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 132 double testMse = SimpleMSEEvaluator.Calculate(testValues, solution.EstimatedTestValues); 133 double trainingRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 134 double testRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(testValues, solution.EstimatedTestValues); 135 results.Add(new Result(BestSolutionTrainingRSquared, new DoubleValue(trainingR2))); 136 results.Add(new Result(BestSolutionTestRSquared, new DoubleValue(testR2))); 137 results.Add(new Result(BestSolutionTrainingMse, new DoubleValue(trainingMse))); 138 results.Add(new Result(BestSolutionTestMse, new DoubleValue(testMse))); 139 results.Add(new Result(BestSolutionTrainingRelativeError, new DoubleValue(trainingRelError))); 140 results.Add(new Result(BestSolutionTestRelativeError, new DoubleValue(testRelError))); 141 #endregion 114 142 } else { 115 143 if (BestSolutionQualityParameter.ActualValue.Value > qualities[i].Value) { … … 120 148 results[BestSolutionResultName].Value = solution; 121 149 results[BestSolutionInputvariableCountResultName].Value = new IntValue(model.InputVariables.Count()); 150 #region update R2,MSE, Rel Error 151 double[] trainingValues = problemData.Dataset.GetVariableValues( 152 problemData.TargetVariable.Value, 153 problemData.TrainingSamplesStart.Value, 154 problemData.TrainingSamplesEnd.Value); 155 double[] testValues = problemData.Dataset.GetVariableValues( 156 problemData.TargetVariable.Value, 157 problemData.TestSamplesStart.Value, 158 problemData.TestSamplesEnd.Value); 159 double trainingR2 = SimpleRSquaredEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 160 double testR2 = SimpleRSquaredEvaluator.Calculate(testValues, solution.EstimatedTestValues); 161 double trainingMse = SimpleMSEEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 162 double testMse = SimpleMSEEvaluator.Calculate(testValues, solution.EstimatedTestValues); 163 double trainingRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues); 164 double testRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(testValues, solution.EstimatedTestValues); 165 results[BestSolutionTrainingRSquared].Value = new DoubleValue(trainingR2); 166 results[BestSolutionTestRSquared].Value = new DoubleValue(testR2); 167 results[BestSolutionTrainingMse].Value = new DoubleValue(trainingMse); 168 results[BestSolutionTestMse].Value = new DoubleValue(testMse); 169 results[BestSolutionTrainingRelativeError].Value = new DoubleValue(trainingRelError); 170 results[BestSolutionTestRelativeError].Value = new DoubleValue(testRelError); 171 #endregion 122 172 } 123 173 }
Note: See TracChangeset
for help on using the changeset viewer.