Changeset 3513 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/BestValidationSymbolicRegressionSolutionVisualizer.cs
- Timestamp:
- 04/23/10 14:28:07 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/BestValidationSymbolicRegressionSolutionVisualizer.cs
r3462 r3513 40 40 public sealed class BestValidationSymbolicRegressionSolutionVisualizer : SingleSuccessorOperator, ISingleObjectiveSolutionsVisualizer, ISolutionsVisualizer { 41 41 private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter"; 42 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 43 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 42 44 private const string SymbolicRegressionModelParameterName = "SymbolicRegressionModel"; 43 45 private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData"; … … 51 53 public ILookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { 52 54 get { return (ILookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; } 55 } 56 public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter { 57 get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 58 } 59 public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter { 60 get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 53 61 } 54 62 public IValueLookupParameter<IntValue> ValidationSamplesStartParameter { … … 85 93 get { return SymbolicExpressionTreeInterpreterParameter.ActualValue; } 86 94 } 95 public DoubleValue UpperEstimationLimit { 96 get { return UpperEstimationLimitParameter.ActualValue; } 97 } 98 public DoubleValue LowerEstimationLimit { 99 get { return LowerEstimationLimitParameter.ActualValue; } 100 } 87 101 public IntValue ValidationSamplesStart { 88 102 get { return ValidationSamplesStartParameter.ActualValue; } … … 99 113 Parameters.Add(new LookupParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The symbolic regression problme data on which the best solution should be evaluated.")); 100 114 Parameters.Add(new LookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of symbolic expression trees.")); 115 Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper limit that should be used as cut off value for the output values of symbolic expression trees.")); 116 Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower limit that should be used as cut off value for the output values of symbolic expression trees.")); 101 117 Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition (part of the training partition).")); 102 118 Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition (part of the training partition).")); … … 112 128 int validationSamplesEnd = ValidationSamplesEnd.Value; 113 129 var validationValues = problemData.Dataset.GetVariableValues(problemData.TargetVariable.Value, validationSamplesStart, validationSamplesEnd); 114 130 double upperEstimationLimit = UpperEstimationLimit.Value; 131 double lowerEstimationLimit = LowerEstimationLimit.Value; 115 132 var currentBestExpression = (from expression in expressions 116 133 let validationQuality = 117 134 SymbolicRegressionMeanSquaredErrorEvaluator.Calculate( 118 135 SymbolicExpressionTreeInterpreter, expression, 136 lowerEstimationLimit, upperEstimationLimit, 119 137 problemData.Dataset, problemData.TargetVariable.Value, 120 138 validationSamplesStart, validationSamplesEnd) … … 126 144 if (bestOfRunSolution == null) { 127 145 // no best of run solution yet -> make a solution from the currentBestExpression 128 UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter );146 UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter, lowerEstimationLimit, upperEstimationLimit); 129 147 } else { 130 148 // compare quality of current best with best of run solution … … 132 150 var bestOfRunValidationQuality = SimpleMSEEvaluator.Calculate(validationValues, estimatedValidationValues); 133 151 if (bestOfRunValidationQuality > currentBestExpression.ValidationQuality) { 134 UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter );152 UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter, lowerEstimationLimit, upperEstimationLimit); 135 153 } 136 154 } … … 140 158 } 141 159 142 private void UpdateBestOfRunSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter) { 143 var newBestSolution = CreateDataAnalysisSolution(problemData, tree, interpreter); 160 private void UpdateBestOfRunSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, 161 double lowerEstimationLimit, double upperEstimationLimit) { 162 var newBestSolution = CreateDataAnalysisSolution(problemData, tree, interpreter, lowerEstimationLimit, upperEstimationLimit); 144 163 if (BestValidationSolutionParameter.ActualValue == null) 145 164 BestValidationSolutionParameter.ActualValue = newBestSolution; … … 169 188 } 170 189 171 private SymbolicRegressionSolution CreateDataAnalysisSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree expression, ISymbolicExpressionTreeInterpreter interpreter) { 190 private SymbolicRegressionSolution CreateDataAnalysisSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree expression, ISymbolicExpressionTreeInterpreter interpreter, 191 double lowerEstimationLimit, double upperEstimationLimit) { 172 192 var model = new SymbolicRegressionModel(interpreter, expression, problemData.InputVariables.Select(s => s.Value)); 173 return new SymbolicRegressionSolution(problemData, model );193 return new SymbolicRegressionSolution(problemData, model, lowerEstimationLimit, upperEstimationLimit); 174 194 } 175 195 }
Note: See TracChangeset
for help on using the changeset viewer.